Skip to content

fix(security): bound structured input validation - #616

Merged
fishmingyu merged 2 commits into
mainfrom
agent/bound-input-validation
Aug 13, 2026
Merged

fix(security): bound structured input validation#616
fishmingyu merged 2 commits into
mainfrom
agent/bound-input-validation

Conversation

@fishmingyu

@fishmingyu fishmingyu commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

Bound structured input validation before large allocations and reject credential-bearing URL authorities without introducing input-size-dependent parser gaps.

These two self-contained hardening commits were extracted from the later #590 storage stack because they do not depend on #586#588.

Changes

  • validate JSON reader block type and size before buffering
  • enforce lexical node, depth, token, item, and element budgets before DOM decoding
  • use linear escape-dense string scanning and retain post-decode complexity validation
  • reject URL userinfo after authority whitespace for standalone and protocol-relative URLs
  • keep embedded prose URLs bounded at whitespace so later email addresses are not misclassified
  • align the short and long URL paths with urlsplit leading WHATWG C0 handling
  • validate the standalone scheme prefix once so repeated embedded separators remain linear
  • add malformed-input, boundary, bounded-memory, scaling, and credential regressions

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Performance improvement
  • Tests

Testing

  • Tests pass locally
  • Added new tests for the changes
  • pytest -q test/test_bounded_json.py test/storage/test_models.py --tb=short: 77 passed
  • independent secret-classifier audit: 50 passed
  • Python 3.10/3.11/3.12 checks across the 8,192/8,193 boundary and leading U+0000..U+0020
  • randomized malformed/valid differential checks and 100k/200k/400k linearity probes
  • pre-commit run --files codenib/_bounded_json.py codenib/_secret_fields.py test/test_bounded_json.py test/storage/test_models.py: passed
  • git diff --check origin/main...HEAD: passed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of the code
  • I have commented the code, particularly in hard-to-understand areas
  • The changes generate no new warnings
  • Any dependent changes have been merged and published

@github-actions github-actions Bot added the type/test Test-related label Aug 13, 2026
@fishmingyu
fishmingyu force-pushed the agent/bound-input-validation branch from d361496 to d9b0db8 Compare August 13, 2026 17:28
@fishmingyu
fishmingyu force-pushed the agent/bound-input-validation branch from d9b0db8 to 797055d Compare August 13, 2026 17:43
@fishmingyu fishmingyu added type/bug Behavior does not match expectations type/perf Performance optimization labels Aug 13, 2026 — with ChatGPT Codex Connector
@fishmingyu
fishmingyu marked this pull request as ready for review August 13, 2026 17:51
@fishmingyu
fishmingyu merged commit b5f8d12 into main Aug 13, 2026
25 checks passed
@fishmingyu
fishmingyu deleted the agent/bound-input-validation branch August 13, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/bug Behavior does not match expectations type/perf Performance optimization type/test Test-related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant