Skip to content

chore: sync core lib and CLAUDE.md from agent-core#35

Closed
avifenesh wants to merge 1 commit into
mainfrom
chore/sync-core-sync-docs-20260529-110048
Closed

chore: sync core lib and CLAUDE.md from agent-core#35
avifenesh wants to merge 1 commit into
mainfrom
chore/sync-core-sync-docs-20260529-110048

Conversation

@avifenesh

Copy link
Copy Markdown
Contributor

Automated sync of lib/ and CLAUDE.md from agent-core.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several ReDoS (Regular Expression Denial of Service) fixes across multiple files by replacing unbounded quantifiers with explicit bounds to prevent polynomial backtracking. The feedback recommends increasing the character limit bound in the hasXML regular expression from 50,000 to 250,000 to avoid false negatives on exceptionally large prompt files.

const hasLists = /^[-*]\s{1,1000}[^\n]{1,2000}$/m.test(content);
// ReDoS fix: bound the unbounded [\s\S]*? so an unterminated <tag> cannot
// drive polynomial backtracking; 50k chars covers any realistic XML block.
const hasXML = /<\w+>[\s\S]{0,50000}?<\/\w+>/.test(content);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The hasXML regex uses a bound of 50000 characters ([\s\S]{0,50000}?). While this prevents ReDoS, very large prompt files (which can easily exceed 50KB, especially when containing extensive few-shot examples or reference documentation) might have their outer XML tags separated by more than 50,000 characters. In such cases, hasXML will incorrectly return false, potentially triggering false positive warnings like Complex content without XML tags.

Consider increasing this limit (e.g., to 250000 or more) to accommodate larger prompt files.

Suggested change
const hasXML = /<\w+>[\s\S]{0,50000}?<\/\w+>/.test(content);
const hasXML = /<\w+>[\s\S]{0,250000}?<\/\w+>/.test(content);

@avifenesh

Copy link
Copy Markdown
Contributor Author

Superseded by latest sync (post ReDoS + prototype-pollution hardening).

@avifenesh avifenesh closed this May 29, 2026
@avifenesh
avifenesh deleted the chore/sync-core-sync-docs-20260529-110048 branch May 29, 2026 11:38
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