Skip to content

fix: escape caller-supplied values in CREST query filters (IAM-11746) - #73

Merged
daveernstingFR merged 2 commits into
mainfrom
polaris/IAM-11746-crest-filter-injection-app-name
Oct 19, 2026
Merged

daveernstingFR merged 2 commits into
mainfrom
polaris/IAM-11746-crest-filter-injection-app-name

Conversation

@daveernstingFR

Copy link
Copy Markdown
Collaborator

Five tools interpolated caller-supplied values directly into CREST
_queryFilter string literals without escaping, so a crafted value could
alter the query: getOidcApp, updateOidcApp, deleteOidcApp,
getTheme, and queryESVs.

This adds a shared escapeCrestStringLiteral helper
(src/utils/crestHelpers.ts) — escapes backslashes, then quotes — and
applies it at all five sites. queryESVs previously escaped quotes only;
it now uses the shared helper. getTheme escapes its value once into a
local variable reused by both clauses of its filter.

Tool schemas, descriptions, and annotations are unchanged. Tools that
accept a caller-written filter expression by design (listOidcApps,
queryManagedObjects, queryLogs) are intentionally unchanged.

Tests

  • Helper unit suite (test/utils/crestHelpers.test.ts): escape cases,
    round-trip through the CREST single-pass decode, and regression guards
    (one input backslash emits exactly two; escape-once contract documented).
  • Per-tool request-construction tests assert the escaped filter in the
    lookup URL for quote and backslash inputs.
  • The existing getTheme quote-escape assertion is updated to require the
    escaped form.

Test plan

  • Single canonical escape helper with round-trip unit tests — Verified by Polaris QA
  • All five sites use the helper — Verified by Polaris QA
  • Injection values yield escaped, literal-only filters (per tool) — Verified by Polaris QA
  • Backslash inputs round-trip safely — Verified by Polaris QA
  • getTheme escapes exactly once (no double-escaping) — Verified by Polaris QA
  • queryESVs local escape replaced by the shared helper — Verified by Polaris QA
  • getTheme test asserts the escaped form — Verified by Polaris QA
  • Tool schemas unchanged (snapshots pass without regeneration) — Verified by Polaris QA
  • Caller-written-filter tools untouched — Verified by Polaris QA
  • Lint, typecheck, tests, format all pass — Verified by Polaris QA
  • Commit messages describe fix and tests, no Jira actions taken — Verified by Polaris QA

🤖 Generated with Claude Code

daveernstingFR and others added 2 commits October 19, 2026 13:18
Values interpolated into CREST _queryFilter string literals were not
escaped, so a crafted value could alter the filter. Added a shared
escapeCrestStringLiteral helper (escapes backslashes, then quotes) and
applied it at the five interpolation sites: the three OIDC app tools,
getTheme, and queryESVs (which previously escaped quotes only).

Tests assert the escaped filter output at the helper and tool level,
including backslash and quote inputs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@daveernstingFR
daveernstingFR merged commit 78ee77c into main Oct 19, 2026
4 checks passed
@daveernstingFR
daveernstingFR deleted the polaris/IAM-11746-crest-filter-injection-app-name branch October 19, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant