feat: harden input parsing with size caps, depth limits, and filesystem validation - #13
Merged
Conversation
Introduce dedicated error variants for payload size, recursion depth, file size, symlink rejection, non-regular files, invalid param identifiers, and body size. Add corresponding safety constants in lib.rs.
…--max-body-size, --allow-symlinks
std::os::unix::fs::symlink and the mkfifo command are POSIX-only. Guard the three tests that depend on them with #[cfg(unix)] so Windows CI runs the two cross-platform tests (oversize rejection and normal file acceptance) and skips the rest.
13 tasks
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.
Summary
Add defense-in-depth security caps to prevent resource exhaustion and filesystem-based attacks:
globsetcrate--allow-symlinksescape hatch)--max-input-sizelimit--max-input-size,--max-payload-size,--max-depth,--max-body-sizeCLI flagsType of Change
Checklist
cargo fmt --allcleancargo clippy --all-targets --all-features -- -D warningscleancargo testpasses locallyCHANGELOG.mdunder[Unreleased](if user-facing)feat:,fix:,docs:, etc.)Testing
tests/security.rs) covering symlink rejection, FIFO rejection, oversize input rejection, and symlink opt-incargo publish --dry-runsucceedsRelated Issues
First phase of input hardening.
Error::BodyTooLargevariant is defined but reserved for a future PR.