fix(pentest): cap the composed additionalContext briefing at 20k chars#3113
Merged
Conversation
The provider has no documented limit (verified against its OpenAPI spec and prompt-injection source), but the composed briefing (user context + all stored notes for a target) was unbounded. Cap at 20,000 chars by dropping whole notes — never cutting one mid-sentence — with an explicit '(N more notes omitted for length)' marker so the agent knows the list is incomplete. User-typed context is always kept (DTO-capped at 4000). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
🎉 This PR is included in version 3.79.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the remaining cubic finding on the production deploy PR (#3111).
The finding's premise was partially off — there is no 4000-character provider contract (verified against Maced's OpenAPI spec and prompt-injection source: no maxLength, no server-side cap; the 4000 limit is our own DTO validation on the user-typed field only). But the underlying point stands: the composed briefing (user context + all stored notes for a target) was unbounded.
This caps it at 20,000 chars:
(N more notes omitted for length — see the finding context notes in Comp AI)marker tells the agent the list is incomplete (no silent truncation)Tests: over-limit note set stays ≤ cap with correct omission marker and intact note bodies; fitting sets get no marker. Module suite: 102 passing.
🤖 Generated with Claude Code
Summary by cubic
Caps the composed pentest
additionalContextbriefing at 20,000 characters to prevent unbounded payloads to the provider. Keeps user context, drops whole notes only, and adds an explicit omission marker when notes are omitted.MAX_ADDITIONAL_CONTEXT_LENGTH = 20_000and updatedbuildAdditionalContextto include only whole notes within the cap.(N more notes omitted for length — see the finding context notes in Comp AI)when truncation occurs.Written for commit 7005712. Summary will update on new commits.