-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add symfony insecure cookie rule
- Loading branch information
Showing
5 changed files
with
619 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
imports: | ||
- php_shared_lang_instance | ||
patterns: | ||
- pattern: | | ||
$<CLASS>::create($<_>, $<_>, $<_>, $<_>, $<_>, $<SECURE>$<...>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: SECURE | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
$<CLASS>::create(secure: $<SECURE>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: SECURE | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
$<CLASS>::create($<_>, $<_>, $<_>, $<_>, $<_>, $<_>, $<HTTP_ONLY>$<...>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: HTTP_ONLY | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
$<CLASS>::create(httpOnly: $<HTTP_ONLY>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: HTTP_ONLY | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
new $<CLASS>($<_>, $<_>, $<_>, $<_>, $<_>, $<SECURE>$<...>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: SECURE | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
new $<CLASS>(secure: $<SECURE>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: SECURE | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
new $<CLASS>($<_>, $<_>, $<_>, $<_>, $<_>, $<_>, $<HTTP_ONLY>$<...>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: HTTP_ONLY | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: | | ||
new $<CLASS>(httpOnly: $<HTTP_ONLY>) | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- variable: HTTP_ONLY | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: $<COOKIE>->withSecure($<SECURE>) | ||
filters: | ||
- variable: COOKIE | ||
detection: php_symfony_insecure_cookie_instance | ||
scope: cursor | ||
- variable: SECURE | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
- pattern: $<COOKIE>->withHttpOnly($<HTTP_ONLY>) | ||
filters: | ||
- variable: COOKIE | ||
detection: php_symfony_insecure_cookie_instance | ||
scope: cursor | ||
- variable: HTTP_ONLY | ||
detection: php_symfony_insecure_cookie_false | ||
scope: cursor | ||
auxiliary: | ||
- id: php_symfony_insecure_cookie_false | ||
patterns: | ||
- "false;" | ||
- id: php_symfony_insecure_cookie_instance | ||
patterns: | ||
- pattern: $<INSTANCE>; | ||
filters: | ||
- variable: INSTANCE | ||
detection: php_shared_lang_instance | ||
scope: cursor | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- pattern: | | ||
$<CLASS>::create() | ||
filters: | ||
- variable: CLASS | ||
regex: \A(Symfony\\Component\\HttpFoundation\\)?Cookie\z | ||
- pattern: $<COOKIE>->$<_>() | ||
filters: | ||
- variable: COOKIE | ||
detection: php_symfony_insecure_cookie_instance | ||
scope: cursor | ||
languages: | ||
- php | ||
metadata: | ||
description: "Insecure options for cookie detected." | ||
remediation_message: | | ||
## Description | ||
To make sure cookies don't open your application up to exploits or | ||
unauthorized access, make sure to set security options appropriately. | ||
## Remediations | ||
✅ Set `httpOnly` to `true` to avoid the cookie being sent by client-side scripts. | ||
✅ Set `secure` to `true` to force cookies to only send over HTTPS. | ||
cwe_id: | ||
- 1004 | ||
- 614 | ||
id: php_symfony_insecure_cookie | ||
documentation_url: https://docs.bearer.com/reference/rules/php_symfony_insecure_cookie |
Oops, something went wrong.