|
| 1 | +id: missing-httponly-java |
| 2 | +language: java |
| 3 | +severity: warning |
| 4 | +message: >- |
| 5 | + Detected a cookie where the `HttpOnly` flag is either missing or |
| 6 | + disabled. The `HttpOnly` cookie flag instructs the browser to forbid |
| 7 | + client-side JavaScript to read the cookie. If JavaScript interaction is |
| 8 | + required, you can ignore this finding. However, set the `HttpOnly` flag to |
| 9 | + true` in all other cases. |
| 10 | +note: >- |
| 11 | + [CWE-1004]: Sensitive Cookie Without 'HttpOnly' Flag |
| 12 | + [OWASP A05:2021]: Security Misconfiguration |
| 13 | + [REFERENCES] |
| 14 | + - https://owasp.org/Top10/A05_2021-Security_Misconfiguration |
| 15 | +utils: |
| 16 | + match_without_httponly: |
| 17 | + kind: argument_list |
| 18 | + has: |
| 19 | + kind: object_creation_expression |
| 20 | + inside: |
| 21 | + stopBy: end |
| 22 | + kind: method_invocation |
| 23 | + |
| 24 | + match_cc2_cookie: |
| 25 | + kind: local_variable_declaration |
| 26 | + precedes: |
| 27 | + kind: expression_statement |
| 28 | + has: |
| 29 | + kind: method_invocation |
| 30 | + has: |
| 31 | + kind: method_invocation |
| 32 | + has: |
| 33 | + kind: argument_list |
| 34 | + has: |
| 35 | + kind: string_literal |
| 36 | + match_nettycookie: |
| 37 | + kind: local_variable_declaration |
| 38 | + all: |
| 39 | + - has: |
| 40 | + stopBy: end |
| 41 | + kind: variable_declarator |
| 42 | + has: |
| 43 | + kind: object_creation_expression |
| 44 | + all: |
| 45 | + - has: |
| 46 | + stopBy: end |
| 47 | + kind: argument_list |
| 48 | + has: |
| 49 | + stopBy: end |
| 50 | + kind: string_literal |
| 51 | + precedes: |
| 52 | + stopBy: end |
| 53 | + kind: string_literal |
| 54 | + - not: |
| 55 | + precedes: |
| 56 | + stopBy: end |
| 57 | + kind: identifier |
| 58 | + regex: "http" |
| 59 | + - not: |
| 60 | + precedes: |
| 61 | + stopBy: neighbor |
| 62 | + kind: expression_statement |
| 63 | + has: |
| 64 | + stopBy: end |
| 65 | + kind: method_invocation |
| 66 | + has: |
| 67 | + stopBy: end |
| 68 | + kind: argument_list |
| 69 | + match_cookie_last: |
| 70 | + kind: argument_list |
| 71 | + has: |
| 72 | + kind: method_invocation |
| 73 | + has: |
| 74 | + kind: argument_list |
| 75 | + has: |
| 76 | + kind: string_literal |
| 77 | + |
| 78 | +rule: |
| 79 | + any: |
| 80 | + - matches: match_cc2_cookie |
| 81 | + - matches: match_without_httponly |
| 82 | + - matches: match_nettycookie |
| 83 | + - matches: match_cookie_last |
0 commit comments