PortSwigger / BChecks

BChecks collection for Burp Suite Professional and Burp Suite Enterprise Edition
https://portswigger.net/burp/documentation/scanner/bchecks
GNU Lesser General Public License v3.0
635 stars 112 forks source link

How to obtain information about a specific header in headers #217

Open Airboi opened 4 months ago

Airboi commented 4 months ago

Current behavior

such like check if jwt token veified,

base.request.headers[potential_header] is Unexpected,can you help me?

metadata:
  language: v1-beta
  name: "JWT Token Signature Validation"
  description: "This BCheck checks if the server verifies the signature of JWT tokens in requests."
  author: "Your Name"
  tags: "JWT", "Security", "Authentication"

run for each:
  potential_header = "Jwt-Token"

given header then
  if "X-Jwt-Token" in {base.request.headers} then
    define:
      jwt_token = {base.request.headers[potential_header]}
      unsigned_token = {jwt_token.split('.')[0] + '.' + jwt_token.split('.')[1] + '.'}

    send request called check_unsigned:
      method: {base.request.method}
      path: {base.request.path}
      headers:
        {potential_header}: {unsigned_token}
      body: {base.request.body}

    if {check_unsigned.response.status_code} is "200" then
      report issue:
        severity: high
        confidence: certain
        detail: "The server does not verify the signature of the JWT token, making it vulnerable to forgery attacks."
        remediation: "Ensure the server validates the signature of JWT tokens before processing the request."
    end if
  end if
Hannah-PortSwigger commented 4 months ago

Hi

You cannot use define within the given ... then block. It must be used before the given ... then block.

To clarify, you wish to extract the value of a specific header from the base response, then use that in an outgoing request as your scan check?

Airboi commented 4 months ago

Yes, I want to extract the JWT token from the base request headers, modify it and request the modified data packet again, check the response to determine if there is a vulnerability with the JWT signature not checked