Repository navigation
fix: bound gzip decompression, sandbox media responses, drop container root, and harden CI workflows - #855
Open
cpriti-os wants to merge 2 commits into
Open
fix: bound gzip decompression, sandbox media responses, drop container root, and harden CI workflows#855cpriti-os wants to merge 2 commits into
cpriti-os wants to merge 2 commits into
Conversation
…r root, and harden CI workflows - Enforce a maximum decompressed output size (128 MiB) in handle_gzip_request and Object.rest_media via decompress_gzip_bounded, returning HTTP 413 if exceeded. - Add Content-Security-Policy: sandbox and X-Content-Type-Options: nosniff headers to Object.rest_media responses. - Run the container image as a dedicated non-root user in Dockerfile. - Set explicit permissions (contents: read) and pin GitHub Actions to commit SHAs across build, docker, and style workflows.
…ckout ref comment
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.
Applies six fixes to
storage-testbench:testbench/common.py): Replace unboundedgzip.decompress(request.data)inhandle_gzip_requestwithdecompress_gzip_bounded(128 MiB cap, HTTP 413 on overflow, supporting concatenated gzip streams).gcs/object.py): Reusedecompress_gzip_boundedfor decompressive transcoding inObject.rest_media.gcs/object.py): SetContent-Security-Policy: sandboxandX-Content-Type-Options: nosniffonObject.rest_mediaresponses so uploaded HTML/SVG objects cannot execute scripts on the testbench origin.Dockerfile): Create and switch to a dedicated non-roottestbenchuser instead of running the server asroot..github/workflows/{build,docker,style}.yaml): Declare top-levelpermissions: { contents: read }on all GitHub Actions workflows..github/workflows/{build,docker,style}.yaml): Pindocker/build-push-actionandactions/setup-pythonto commit SHAs instead of mutable tags.Testing
tests/test_common.py(test_decompress_gzip_bounded_within_limit,test_decompress_gzip_bounded_concatenated_streams,test_decompress_gzip_bounded_exceeds_limit) andtests/test_object.py(test_rest_media_sets_sandbox_security_headers,test_rest_media_bounded_gzip_transcode).isortandblack==22.3.0; verified withpytest.