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

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

Open
Airboi opened this issue Jul 10, 2024 · 2 comments
Open

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

Airboi opened this issue Jul 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Airboi
Copy link

Airboi commented Jul 10, 2024

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
@Airboi Airboi added the bug Something isn't working label Jul 10, 2024
@Hannah-PortSwigger
Copy link
Contributor

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
Copy link
Author

Airboi commented Jul 11, 2024

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

@PortSwiggerWiener PortSwiggerWiener added enhancement New feature or request and removed bug Something isn't working labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants