Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative directive in the template matcher seems to not work with the case-insensitive directive #5169

Open
x676f64 opened this issue May 10, 2024 · 0 comments
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@x676f64
Copy link

x676f64 commented May 10, 2024

Nuclei version: v3.2.4

Current Behavior:

Nuclei fails to match on a finding when the case-insensitive directive and the negative directive are used together.
For example, the cookies-without-httponly-secure matcher should only identify endpoints that lack both httponly and secure but the strings they match on have different cases depending on the web server. I observed this issue in the wild so attempted to modify the template to use case-insensitivity with negative but it does not appear to work.

Expected Behavior:

The expected behavior is that this template will only return a positive finding if both httponly and secure exist in the set-cookie directive but do to case variations of web servers, this is not always a match. Attempting to add the case-insensitive directive did not work.

I have to build a template like this to properly handle the potentials and this still doesn't cover some crazy edge case.

id: cookies-without-httponly-secure

info:
  name: Cookies without HttpOnly or Secure attribute - Detect
  author: princechaddha,Mr.Bobo HP
  severity: info
  description: |
    Checks whether cookies in the HTTP response contain the HttpOnly attribute. If the HttpOnly flag is set, it means that the cookie is HTTP-only
  impact: |
    Lack of HttpOnly flag on cookies increases the risk of client-side attacks, compromising user session security and data privacy.
  remediation: |
    Ensure that all cookies are set with the HttpOnly attribute to prevent client-side access.
  reference:
    - https://owasp.org/www-community/HttpOnly
  classification:
    cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
    cvss-score: 0
  metadata:
    verified: true
    max-request: 1
  tags: misconfig,http,cookie,generic

http:
  - method: GET

    extractors:
      - type: regex
        part: header
        regex:
          - "Set-Cookie:.*"
    path:
      - "{{BaseURL}}"

    host-redirects: true
    max-redirects: 2
    matchers-condition: and
    matchers:
      - type: word
        part: header
        words:
          - 'Set-Cookie'
        condition: and
      - type: word
        part: header
        words:
          - "httponly"
          - "secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "httpOnly"
          - "secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "HttpOnly"
          - "secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "HttpOnly"
          - "Secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "httpOnly"
          - "Secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "httonly"
          - "Secure"
        negative: true
        condition: and
      - type: word
        part: header
        words:
          - "HTTPONLY"
          - "SECURE"
        negative: true```

### Steps To Reproduce:
`echo "example.com" |nuclei -id cookies-without-httponly-secure -debug`
(You will need to find affected targets as I can't share that information)
### Anything else:

@x676f64 x676f64 added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

1 participant