Parser and archive safety
Parsing changes the risk
A parser converts bytes into structured information. Archives can contain many entries and compressed data; image and document readers may allocate substantial memory. A small input size alone does not bound the work. Define a budget for received bytes, processed bytes, entry count, depth, time, memory and concurrency.
Review an archive before processing
A safe design checks intended member destinations, permitted regular-file types, duplicate destinations and resource budgets. Reject unexpected links or unsupported archive features. Extract only in a dedicated isolated workspace using vetted APIs; enforce containment and actual output limits during processing because metadata is untrusted. Do not construct or extract hostile archives for this lesson.
Example: a processing budget
For a fictional batch, allow at most three regular entries and 120 decoded bytes total, with an approved destination for every member. A report of two entries totaling 80 bytes can proceed to controlled processing. A report of four entries totaling 80 bytes fails the count policy. If actual decoded output exceeds the budget, stop and clean up partial results; a metadata pass is not approval for release.
Deserialize data, not behavior
For a note index, prefer a data-only interchange format such as JSON with explicit schema, type and length checks. Do not deserialize untrusted native objects (for example Python pickle). Even JSON needs bounded input and parser resources. Run maintained parsers in low-privilege workers without unnecessary network or secrets, and treat failed processing as a non-release state.
Practice: check abstract records
Use the synthetic archive reports in the lab. Predict whether each is eligible for the next stage. Describe how to test output limits with tiny ordinary data, and why a test of abstract destination flags does not demonstrate real filesystem containment. No archive generation is required.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Parser and archive safety — knowledge check
Apply file security principles to fictional scenarios.
Four regular entries total 80 bytes. Toy budget allows three. Decision?
Why monitor actual decoded output?
Which approach is appropriate for untrusted note index data?
What should a processing worker have?
What does an abstract destination flag test prove?