Security: Fix DoS risks, patch XXE vulnerability, and add security he…#7222
Security: Fix DoS risks, patch XXE vulnerability, and add security he…#7222walle5eva wants to merge 2 commits intohotosm:developfrom
Conversation
for more information, see https://pre-commit.ci
|
❌ The last analysis has failed. |
|
Thanks you @walle5eva for the work on this PR and for the security hardening here, really appreciate it. The timeout, headers, and XML-related changes are useful. |
This pull request addresses several security vulnerabilities identified during a security audit using Bandit (SAST) and OWASP ZAP (DAST).
Replaced the standard, insecure xml.etree.ElementTree parser with the secure defusedxml equivalent in the mapping services and test helpers to prevent potential XML attacks.
Added defusedxml to requirements.txt.
Added a standard timeout=30 parameter to multiple requests.get() and requests.post() calls across the backend (general.py, osm_service.py, project.py, etc.). This prevents the server from hanging indefinitely if external APIs (like GitHub or OSM) fail to respond.
Implemented a FastAPI middleware in the main application file to automatically append essential security headers to all responses.
Added X-Content-Type-Options: nosniff to prevent MIME-sniffing.
Added X-Frame-Options: SAMEORIGIN to mitigate clickjacking.
Added a basic Content-Security-Policy.
These changes were made as part of an open-source security contribution for a university computer security course.