Skip to content

fix(redaction): bound XML attribute scanning - #691

Closed
luvs01 wants to merge 1 commit into
devfrom
codex/investigate-vulnerability-in-opencodex
Closed

luvs01 wants to merge 1 commit into
devfrom
codex/investigate-vulnerability-in-opencodex

Conversation

@luvs01

@luvs01 luvs01 commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • A newly introduced full-terminal redaction path exposed untrusted assistant output to a suffix-searching XML-attribute regex that can exhibit quadratic CPU cost on repeated unterminated tags and thereby block the event loop.

Description

  • Replace the quadratic identifying-attribute regex with a single-pass tag scanner (maskXmlIdentifyingAttribute) that scans each tag once and preserves the folded matching and original-offset mapping used by foldForMatching.
  • Integrate the new scanner into the framing pass by calling it from maskOtherFramings so credential masking is still applied for XML attribute and tag-name framings.
  • Keep existing credential-masking semantics (tag-name, name|key|id attributes, multipart, colon-labelled, and value patterns) while avoiding repeated suffix lookahead over unterminated tags.
  • Add a bounded-time regression test tests/lib/redact.test.ts that asserts repeated unterminated tags (e.g. "<a ".repeat(8000)) are scanned in bounded time and unchanged when not credential-bearing.

Testing

  • Ran focused unit suites with ./node_modules/.bin/bun test tests/lib/redact.test.ts tests/responses/responses-canonical-nonstream.test.ts tests/responses/sse-failed-tail.test.ts and observed the focused runs pass (139 passed, 0 failed).
  • Ran type checking with bun x tsc --noEmit, structure verification with bun run structure:check, and privacy scan with bun run privacy:scan, all of which completed successfully for the modified areas.
  • Ran git diff --check to confirm no whitespace/patch issues; the full repository test run was not used to gate this focused fix because some unrelated integration tests failed in this checkout; the redaction- and delivery-focused tests and typecheck passed.

Codex Task


Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Improved credential redaction in XML, including credentials identified by tag names or attributes.
  • Tests
    • Added a regression test covering large inputs with unterminated, non-credential tags.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 69069649-9e8e-43d8-9039-f4ebb2c02c4e

📥 Commits

Reviewing files that changed from the base of the PR and between d4480b7 and f42e713.

📒 Files selected for processing (2)
  • src/lib/redact.ts
  • tests/lib/redact.test.ts

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


📝 Walkthrough

Walkthrough

XML credential redaction now uses a separate scanner to check tag attributes in decoded and raw input. A performance regression test covers repeated unterminated tags that do not contain credential labels.

Changes

XML credential redaction

Layer / File(s) Summary
XML attribute scanning and validation
src/lib/redact.ts, tests/lib/redact.test.ts
The general XML framing rule for credential-valued name, key, or id attributes was removed. A separate scanner checks XML tag attributes in decoded and raw input. When an attribute matches a credential label, it preserves the text through the tag name and masks the rest of the input. The regression test checks that 8,000 repeated unterminated non-credential tags remain unchanged and complete in under 1,000 ms.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: lidge-jun, ingwannu

Merge Risk: ⚪ Minimal · up to f42e7

The XML scanning change addresses repeated unterminated tags while retaining credential masking. No actionable issue prevents merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. 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 accurately and concisely describes the main change: bounding XML attribute scanning in the redaction logic to avoid quadratic behavior.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 30, 2026

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Devin Review

Comment thread tests/lib/redact.test.ts
Comment on lines +340 to +342
const started = performance.now();
expect(redactSecretString(input)).toBe(input);
expect(performance.now() - started).toBeLessThan(1_000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Fixed timing threshold may make the regression test flaky

The 1,000 ms limit measures the entire redaction pipeline. A busy CI worker could fail it even when XML scanning remains linear; consider comparing input-size scaling instead.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@luvs01

luvs01 commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@luvs01 luvs01 closed this Sep 30, 2026
lidge-jun pushed a commit to lidge-jun/opencodex that referenced this pull request Sep 30, 2026
* fix(redaction): bound XML identifying-attribute scans

Carry luvs01#691 at f42e713. Replace wall-clock regression with delimiter-work accounting and preserve malformed/escaped credential coverage.

* fix(redaction): recognize quoted XML tag delimiters

Scan tag terminators outside quoted values, cover credential masking after embedded delimiters, and count manual character work in linear-scaling regressions.
@github-actions
github-actions Bot deleted the codex/investigate-vulnerability-in-opencodex branch October 15, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant