Skip to content

fix(pentest): cap the composed additionalContext briefing at 20k chars#3113

Merged
tofikwest merged 2 commits into
mainfrom
tofik/pentest-context-review-fixes
Jun 12, 2026
Merged

fix(pentest): cap the composed additionalContext briefing at 20k chars#3113
tofikwest merged 2 commits into
mainfrom
tofik/pentest-context-review-fixes

Conversation

@tofikwest

@tofikwest tofikwest commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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:

  • whole notes are dropped, never cut mid-sentence
  • an explicit (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)
  • user-typed context is always kept (already DTO-capped at 4000)
  • the report appendix is deliberately NOT capped — auditors should always see every note

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 additionalContext briefing 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.

  • Bug Fixes
    • Added MAX_ADDITIONAL_CONTEXT_LENGTH = 20_000 and updated buildAdditionalContext to include only whole notes within the cap.
    • Appends an omission marker (N more notes omitted for length — see the finding context notes in Comp AI) when truncation occurs.
    • Always includes user-provided context (already DTO-capped at 4000).
    • Added tests for fit/over-limit cases, omission marker behavior, and ensuring notes aren’t cut mid-sentence.

Written for commit 7005712. Summary will update on new commits.

Review in cubic

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>
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment Jun 12, 2026 12:20am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Jun 12, 2026 12:20am
portal Skipped Skipped Jun 12, 2026 12:20am

Request Review

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@vercel vercel Bot temporarily deployed to Preview – app June 12, 2026 00:19 Inactive
@vercel vercel Bot temporarily deployed to Preview – portal June 12, 2026 00:19 Inactive
@tofikwest tofikwest merged commit c60a1b8 into main Jun 12, 2026
11 checks passed
@tofikwest tofikwest deleted the tofik/pentest-context-review-fixes branch June 12, 2026 00:21
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.79.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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