Skip to content

feat: harden input parsing with size caps, depth limits, and filesystem validation - #13

Merged
Arkptz merged 12 commits into
mainfrom
feat/input-hardening
Apr 22, 2026
Merged

feat: harden input parsing with size caps, depth limits, and filesystem validation#13
Arkptz merged 12 commits into
mainfrom
feat/input-hardening

Conversation

@Arkptz

@Arkptz Arkptz commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

Add defense-in-depth security caps to prevent resource exhaustion and filesystem-based attacks:

  • Cap TNetString payload size at 256 MiB and recursion depth at 256 levels
  • Cap JSON-to-schema conversion depth at 64 levels
  • Replace hand-rolled glob matcher with battle-tested globset crate
  • Reject symlinks, FIFOs, and non-regular files by default (with --allow-symlinks escape hatch)
  • Validate input file size against configurable --max-input-size limit
  • Validate path parameter identifiers against safe character set
  • Bound HAR format-detection read to 4 KiB instead of reading entire file
  • Expose --max-input-size, --max-payload-size, --max-depth, --max-body-size CLI flags

Type of Change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Documentation update
  • Refactoring / internal cleanup
  • CI / build / tooling

Checklist

  • cargo fmt --all clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test passes locally
  • Added or updated tests for the change
  • Updated README / CLI help text if user-facing behavior changed
  • Added entry to CHANGELOG.md under [Unreleased] (if user-facing)
  • Used conventional commit style in commit messages (feat:, fix:, docs:, etc.)

Testing

  • Unit tests added for TNetString payload cap and depth limit
  • Unit test for JSON schema depth limit
  • Unit tests for path parameter identifier validation
  • Integration test suite (tests/security.rs) covering symlink rejection, FIFO rejection, oversize input rejection, and symlink opt-in
  • All 192 lib tests + 5 security integration tests pass
  • cargo publish --dry-run succeeds

Related Issues

First phase of input hardening. Error::BodyTooLarge variant is defined but reserved for a future PR.

@Arkptz
Arkptz merged commit 3ba0288 into main Apr 22, 2026
12 checks passed
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