fix: harden deserialization, path traversal, log redaction, and size limits #57
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
Fix all 5 security vulnerabilities reported in #55 (code audit findings), ordered by severity.
Closes: #55
Changes
_RestrictedUnpickler+_safe_unpicklereplace rawpickle.loads()inpaperqa.pyandpaperqa_mcp_server.py. Only allows basic Python builtins (dict,str,int, etc.), blocking arbitrary code execution from crafted index files._validate_index_name()rejects..,/,\, null bytes. Applied at 7 path-construction entry points acrosspaperqa.py,paperqa_mcp_server.py, andleann.py._paperqa_find_crashing_file()now verifies all returned paths are withinpaper_directoryviais_relative_to(). Additional guard incli/ask.pybeforef.unlink()._redact_cmd()inleann.pymasks--api-key/--embedding-api-keyvalues with***in 3 debug/error log locations._safe_zlib_decompress()(100MB limit),_MAX_DOWNLOAD_SIZE(500MB) check on Content-Length + body,_MAX_TAR_MEMBER_SIZE/_MAX_TAR_TOTAL_SIZEfor tarball extraction.test_paperqa.py,test_leann.py,test_paper.py.headersattribute toMockResponseintest_figure_extraction.py(required by new download size check).Type of Change
Testing
make check(required) — 470 passed, 0 failed, lint clean, 75.80% coverageChecklist