Repository navigation
feat(guardrails): inspect oversized content instead of skipping (#172) - #179
Merged
Merged
Conversation
The maxContentBytes (256 KiB) skip-inspection behavior was a security gap: an attacker could pad a payload past the bound to skip inspection, and benign large content was never judged on its merits. 'Too big to check' is not an acceptable terminal state for a security control. Removes the maxContentBytes const, the onContentTooLarge method, and the early-return arm in check(). The checker now inspects content regardless of size; a checker timeout/error on huge input flows through the existing onCheckerError fail-open/closed path (the 30s guardrailCheckTimeout bounds the failure mode). minContentBytes (Post-only cost gate), maxSanitizedBytes (sanitize-laundering defense), and failureStreak are left untouched. Tests: deleted TestOversizedContentEnforceDoesNotSilentlyPass (asserted the skip); added TestOversizedContentIsInspected (proves the checker IS called on oversized content) + TestOversizedContentCheckerTimeoutFailClosed (proves a checker error on huge input flows through onCheckerError). Decision recorded in ADR 0050 (supersedes the maxContentBytes clause of ADR 0021). The ADR acknowledges the N× concurrent checker-cost amplification under the read-parallel fan-out as an accepted trade-off. Follow-up: #178 (MCP tool results are not truncated to MaxOutputBytes). Closes #172.
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.
What
Removes the
maxContentBytes(256 KiB) skip-inspection behavior from guardrails. The checker now inspects tool content regardless of size; a checker timeout/error on huge input flows through the existingonCheckerErrorfail-open/closed path (the 30sguardrailCheckTimeoutbounds the failure mode).Why
"Too big to check" is not an acceptable terminal state for a security control. The bound was a gap on both sides: an attacker could pad a payload past 256 KiB to skip inspection, and benign large content was never judged on its merits. The 30s checker timeout + fail-open/closed already bound the failure mode.
Same class of decision as #168 / ADR 0049 (remove maxChecks): a cost guard whose skip behavior is a security downgrade for a control the operator explicitly opted into.
Changes
internal/adapter/modelhook/modelhook.go— deletedmaxContentBytesconst,onContentTooLargemethod, and the early-return arm incheck().minContentBytes,maxSanitizedBytes, andfailureStreakuntouched.TestOversizedContentEnforceDoesNotSilentlyPass; addedTestOversizedContentIsInspected+TestOversizedContentCheckerTimeoutFailClosed.maxContentBytesclause of ADR 0021. Acknowledges the N× concurrent checker-cost amplification as an accepted trade-off.Follow-up
Closes #172.