rusackas opened a new pull request, #40664:
URL: https://github.com/apache/superset/pull/40664

   ### SUMMARY
   
   Defense-in-depth hardening for ZIP/extension processing:
   
   - **`check_is_safe_zip`** (`superset/utils/core.py`) enforced only per-file 
size and the per-archive compression ratio. It did **not** bound the **total** 
decompressed size — an archive of many individually-allowed entries (each ≤ 
`ZIPPED_FILE_MAX_SIZE`, ratio ≤ `ZIP_FILE_MAX_COMPRESS_RATIO`) could still sum 
to a very large decompressed total and exhaust memory. Added a 
`ZIP_FILE_MAX_TOTAL_SIZE` cap (default 1GB). Also guarded the ratio division so 
an entry reporting `compress_size == 0` raises a clean `SupersetException` 
instead of `ZeroDivisionError`.
   - **`BACKEND_REGEX`** (`superset/extensions/utils.py`) used `(.+)`, which 
could capture `..` components. Tightened to reject parent-path components 
(defense-in-depth; `check_is_safe_zip` already runs before extraction, and the 
capture is used to build an in-memory module name rather than a filesystem 
path).
   
   (Note: FINDING-035 — import filename-extension validation — is intentionally 
**not** included; the `is_zipfile()` content check is the authoritative, 
stronger validation, and requiring a `.zip` extension would risk breaking API 
clients for negligible benefit. FINDING-034/036 were confirmed 
already-mitigated.)
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/unit_tests/utils/test_core.py -k safe_zip
   ```
   
   New tests: total decompressed size over the cap is rejected; a zero 
compressed size no longer raises `ZeroDivisionError`.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to