Skip to content

fix(integrations): remove unsafe generic ServiceNow table tools - #4206

Closed
kojiwakayama wants to merge 3 commits into
mainfrom
codex/fix-servicenow-tools-bearer-token-leak
Closed

kojiwakayama wants to merge 3 commits into
mainfrom
codex/fix-servicenow-tools-bearer-token-leak

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

  • A set of newly added generic ServiceNow table tools accepted a caller-controlled instanceHost while the connector attached the sensitive SERVICENOW_ACCESS_TOKEN as an Authorization: Bearer header, allowing a caller to direct the token to an arbitrary host.
  • This change removes the attack surface by eliminating the tools that permit an untrusted caller to set the request host while credentials are forwarded.
  • Preserve curated ServiceNow operations (incident create/update, etc.) that are scoped to the trusted instance configuration.

Description

  • Removed the generic query_table, create_table_record, and update_table_record tool definitions from the ServiceNow connector template at cli/templates/integrations/servicenow/connector.json so callers can no longer supply instanceHost for those generic operations.
  • Regenerated the integration catalog entries in src/integrations/_data.ts to exclude the unsafe generic ServiceNow tools.
  • Updated src/integrations/_data.test.ts to add regression assertions that the three generic ServiceNow table tools are not present and to assert that curated incident operations remain available.

Testing

  • Ran python3 -m json.tool cli/templates/integrations/servicenow/connector.json to validate the template JSON, which succeeded.
  • Verified there are no remaining occurrences with rg -n 'servicenow__(query_table|create_table_record|update_table_record)' cli/templates/integrations/servicenow/connector.json src/integrations/_data.ts, which returned no matches.
  • Ran git diff --check to ensure no whitespace/format issues, which passed.
  • Attempted deno test --no-check --allow-all src/integrations/_data.test.ts but deno is not installed in this environment, so unit tests were not executed here (the change includes focused test adjustments; please run the suite in a Deno-enabled CI or dev environment).

Codex Task

Summary by CodeRabbit

  • New Features
    • Improved ServiceNow integration support for interactions, knowledge access, and incident workflows.
    • ServiceNow connections now accept either a hostname or HTTPS URL and automatically normalize the instance address.
    • Requests are securely restricted to the configured ServiceNow instance.
  • Bug Fixes
    • Improved validation and error messages for missing or invalid ServiceNow instance configuration.
    • Updated request links and endpoint handling to use the configured instance consistently.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 3 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f22f5532-4989-4713-a23e-20989ed3ba14

📥 Commits

Reviewing files that changed from the base of the PR and between f8c0536 and 4e65287.

📒 Files selected for processing (1)
  • docs/api-reference/veryfront/integrations.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53005a8c-c14e-44c2-8b29-61b714936fbc

📥 Commits

Reviewing files that changed from the base of the PR and between a2a3938 and f8c0536.

📒 Files selected for processing (6)
  • src/integrations/_data.test.ts
  • src/integrations/_data.ts
  • src/integrations/local-credential-auth.ts
  • src/integrations/local-tool-source.test.ts
  • src/integrations/local-tool-source.ts
  • templates/integrations/servicenow/connector.json

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

ServiceNow endpoints now derive their host from SERVICENOW_INSTANCE. Instance values are validated and normalized to HTTPS origins. Generic table tools were removed. Integration tests cover endpoint curation, validation, authentication, origin binding, and missing credentials.

Changes

ServiceNow instance routing

Layer / File(s) Summary
Curated ServiceNow catalog
src/integrations/_data.ts, templates/integrations/servicenow/connector.json, src/integrations/_data.test.ts
ServiceNow metadata and endpoints now use SERVICENOW_INSTANCE. Generic table query, create, and update tools were removed. Tests verify the curated endpoints and trusted host templates.
Trusted instance validation and execution
src/integrations/local-credential-auth.ts, src/integrations/local-tool-source.ts, src/integrations/local-tool-source.test.ts
ServiceNow instance values accept bare hosts or HTTPS URLs, normalize to HTTPS origins, reject invalid forms, and bind requests to the configured origin. Tests cover authentication, rejection, and missing credentials.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to f8c05

The change removes unsafe generic ServiceNow table tools while preserving the HTTPS endpoint behavior, and no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: kwakayama

Sequence Diagram(s)

sequenceDiagram
  participant ToolSource
  participant LocalCredentialAuth
  participant ServiceNowTransport
  ToolSource->>LocalCredentialAuth: Resolve SERVICENOW_INSTANCE
  LocalCredentialAuth-->>ToolSource: Return normalized instanceOrigin
  ToolSource->>ServiceNowTransport: Substitute instanceOrigin into endpoint
  ServiceNowTransport->>ServiceNowTransport: Enforce instanceOrigin as allowed origin
  ServiceNowTransport-->>ToolSource: Return authenticated response
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (2 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: removing unsafe generic ServiceNow table tools. It matches the pull request objectives and changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (2 skipped: 1 unsupported, 1 too large.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-servicenow-tools-bearer-token-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfe26e45da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/integrations/_data.test.ts

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4348e6f33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/integrations/_data.ts
Comment thread src/integrations/_data.test.ts
@kwakayama

kwakayama commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

This patch is consolidated into #4224 at final SHA 1bfb35a. The rollup carries removal of unsafe generic ServiceNow table tools plus host-pattern enforcement before transport/credential work. This PR will be closed as superseded after #4224 merges.

@kojiwakayama
kojiwakayama force-pushed the codex/fix-servicenow-tools-bearer-token-leak branch from a4348e6 to 2ebecc8 Compare August 25, 2026 17:36

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ebecc8215

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread templates/integrations/servicenow/connector.json
Squashed from:
- fix(integrations): remove unsafe generic ServiceNow tools
- fix(integrations): bind ServiceNow endpoint hosts to SERVICENOW_INSTANCE
@kojiwakayama
kojiwakayama force-pushed the codex/fix-servicenow-tools-bearer-token-leak branch from 2ebecc8 to 1e05701 Compare August 25, 2026 17:39

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 330 1972 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

Admission rejected the new {{env.SERVICENOW_INSTANCE}} endpoint templates
because assertHttpsCatalogUrl refuses any URL containing a template, so
every ServiceNow tool failed at source creation. Admit ServiceNow
endpoints by their trusted template prefix (mirroring the Salesforce
instance-origin binding) and substitute the host at execution with an
HTTPS origin normalized from the SERVICENOW_INSTANCE configuration.

The normalization accepts both shapes existing configurations use, a
bare host (example.service-now.com) and a full HTTPS URL, matching the
scaffolded ServiceNowClient and OAuth route, so a full-URL value no
longer composes an invalid https://https:// endpoint. SERVICENOW_INSTANCE
is now a required credential of the ServiceNow auth plan, so a missing or
malformed value surfaces as a clear credential or configuration error
before any request is sent.

Also align the public connector description with the retained curated
tools now that the generic change_request-capable table tools are gone.

Regenerated src/integrations/_data.ts via
scripts/build/generate-integrations-module.ts. Added local tool-source
tests covering admission plus execution against the env-bound host, the
instance normalization shapes, malformed instance rejection, and the
missing-credential path.

Claude-Session: https://claude.ai/code/session_012VprCnNBzAi9PRvzhjYNcb

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: f8c0536b84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.15663% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/integrations/local-tool-source.ts 68.42% 4 Missing and 2 partials ⚠️
src/integrations/local-credential-auth.ts 93.18% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kojiwakayama has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 4e65287162

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sonarqubecloud

Copy link
Copy Markdown

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Superseded by #4224, which consolidates this security hardening and is now merged at exact head 47e9834c65e71f9bed68204595626943bff349a2.

@kojiwakayama
kojiwakayama deleted the codex/fix-servicenow-tools-bearer-token-leak branch August 30, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants