feat(python/django): add rule to detect missing SecurityMiddleware - #3804
feat(python/django): add rule to detect missing SecurityMiddleware#3804balaakasam wants to merge 2 commits into
Conversation
|
|
|
Hello team, just checking in on this PR. Happy to make any if needed adjustments to get this to closure. Please let me know |
|
Hi, just following up. CLA is now signed and all checks are passing. Happy to make any adjustments if needed, waiting to hear back. Thanks you. |
|
Hi team, following up to see if anything else is needed from my end to get this going. Please let me know. Thank you. |
1 similar comment
|
Hi team, following up to see if anything else is needed from my end to get this going. Please let me know. Thank you. |
|
Hi team, following up to see if anything else is needed from my end to get this going as this has been open since a very long time. Please let me know. Thank you. |
Summary
This PR adds a new Semgrep rule to detect when Django's SecurityMiddleware is missing from the MIDDLEWARE setting in Django applications.
Problem
Django's SecurityMiddleware provides several critical security protections:
When SecurityMiddleware is absent, none of these protections are active, leaving web applications — particularly ecommerce applications handling payment and personal data - exposed to common web attacks and non-compliant with PCI-DSS requirements.
This misconfiguration is common and does not currently have a rule in the Semgrep registry.
Changes
missing-security-middleware.yaml- rule targeting Python/Django settings files where MIDDLEWARE list does not include SecurityMiddlewaremissing-security-middleware.py- test file with positive case (missing middleware, should trigger) and negative case(middleware present, should not trigger)
References