Skip to content
Smuggling / CRLF Write-up Advanced

“ParseThru” – Exploiting HTTP Parameter Smuggling in Golang

A vulnerability in Golang's URL parsing allows HTTP parameter smuggling when a front-end service running Go 1.17 or later forwards a request with a semicolon in the query string to a back-end service running an earlier version. An attacker could bypass authorization checks, as demonstrated in Harbor where an authenticated user could read restricted image layers.

Daniel Abeles Follow

Published on oxeye.io

Oxeye’s security research team has found a security vulnerability in Golang-based applications. Under certain conditions, it lets a threat actor bypass validations based on HTTP request parameters due to the use of unsafe URL parsing.

Daniel Abeles (@Daniel_Abeles), Gal Goldsthein (@G4lGo89), on oxeye.io

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

Oxeye's security research team found a vulnerability in Golang-based applications that lets an attacker bypass validations built on HTTP request parameters. The root of it is unsafe URL parsing: different Golang versions disagree about what a semicolon means inside a query string, and a reverse proxy helper forwards the raw query without parsing it. When two services in a chain run different Golang versions, a parameter that the front service does not see can reappear at the back service.

The report was published on 28 July 2022. On 10 October 2022, CVE-2022-2880 was assigned to the vulnerability and the Golang team patched it in an update. On 23 October 2022, the NVD updated the entry with a HIGH severity rating and a CVSS score of 7.5.

The case study is Harbor, an open source registry that secures artifacts with policies and role-based access control. Harbor is a CNCF Graduated project and lets you centralise multiple image registries under one roof. It uses the distribution container registry to store and manage Docker images. The feature at the centre of the case is Cross Repository Blob Mount, which saves disk space and network bandwidth when storing or uploading Docker images that point to the same file system layers.

Setup

The precondition is a deployment where two Golang services sit in a chain and run different versions. The first is a user-facing application on Golang 1.17 or later; the second, a backend service, runs on an earlier version.

For the Harbor case, Oxeye looked for deployments with this version discrepancy and found that Bitnami, a company acquired by VMware that holds Helm charts and Docker images for various projects, had this exact setup: its core Harbor microservice runs on Golang 1.17, while the Docker registry microservice runs on version 1.15.

The attacker needs an authenticated account. Even the lowest permission level is enough. To complete the exploit, the attacker also needs to know a blob digest hash to mount; the report says this challenge is discussed in the next blog post.

Finding it

URL parsing is normally done according to RFC 3986, which describes the components of a URL:

From the original on oxeye.io

Every language implements this logic itself: Python has urllib.parse, Golang has net/url. Each follows the same guidelines but contains minor differences, and those differences produce parsing inconsistencies on the same input.

Golang's core team released a patch that fundamentally changed how the language parses URLs. Before version 1.17, Golang treated a semicolon inside the query portion of a URL as a valid delimiter, the same way it treats an ampersand. The behaviour comes from the parseQuery method:

From the original on oxeye.io

So a URL like the one below yields two query parameters, name and company, rather than a single name parameter:

From the original on oxeye.io

From version 1.17, parseQuery returns an error if the URL query contains a semicolon:

From the original on oxeye.io

But the fix was incomplete. One of the methods responsible for getting the parsed query string ignores the returned error:

From the original on oxeye.io

Separately, Golang offers a built-in function to proxy HTTP traffic through its httputil/reverseproxy.go module. To create a new reverse proxy it provides the NewSingleHostReverseProxy method:

From the original on oxeye.io

That method takes the raw query string from the request rather than the parsed one, and it does not parse it: it sends it as is.

Exploitation

Step 1: understand the chain

Consider two Golang-based services. The first is user-facing and runs 1.17 or later; the second is a backend on an earlier version. A user makes an HTTP request to the first service with a name query parameter, and the first service decides whether to pass the request through based on that parameter.

From the original on oxeye.io

Step 2: append a semicolon

If the user appends a semicolon to the name parameter, the first service ignores its existence when parsing the query string. Instead of making a logic decision based on it, the service forwards the request to the backend. The backend receives the transaction and treats the parameter without the semicolon. Requests containing query parameters that would normally be rejected are therefore smuggled through.

Step 3: the Harbor blob mount request

Reading the Docker registry V2 API, the researchers found the endpoint that allows a Cross Repository Blob Mount. A request that attempts to mount a blob from a different repository looks like this:

From the original on oxeye.io

To mount a blob from a foreign repository, the endpoint expects one URL path parameter, name, which specifies the target repository, and two query parameters:

  • mount: the hash digest of the layer to be mounted
  • from: the foreign repository name that already holds the referenced layer

When Harbor receives such a request it performs two permission validations:

  1. It checks whether the user has push access to the repository in the URL parameter <name>.
  2. It checks whether the user has pull access from the repository in the query parameter <from>.

Step 4: send it twice

Oxeye sent the cross-repository blob mount request through Harbor twice: once with a valid from value, and once with the same parameter carrying a trailing semicolon.

The original request was blocked by Harbor's authorization checks:

From the original on oxeye.io

The modified request bypassed those checks, and the response confirms that the blob, received from the registry, mounted successfully:

From the original on oxeye.io

Root cause

The mistake is a disagreement between two parsers about the same string. In Golang before 1.17, parseQuery treats a semicolon in the query as a delimiter, so from=x; is read as the parameter from with value x. From 1.17, parseQuery returns an error on a semicolon, but the method that retrieves the parsed query string ignores that error, so the front service does not see the parameter at all. Meanwhile NewSingleHostReverseProxy forwards the raw query string unchanged, so the backend on the older version parses the semicolon away and sees the parameter as intended.

In Harbor's case, the front microservice on 1.17 does not recognise the from parameter when it carries a trailing semicolon, so the pull-access check on the foreign repository is not applied, while the registry microservice on 1.15 reads the parameter normally and performs the mount. The existing defence, the two permission validations, is bypassed because one of the two inputs it depends on is invisible to the component enforcing it.

Impact

Under specific deployments, an authenticated user, even with the lowest permission level, can issue a special request to read image layers of restricted projects they do not have access to. The attacker must know a blob digest hash to mount it. More generally, miscreants can smuggle requests containing query parameters that normally would be rejected. During the research, Oxeye found multiple instances of this vulnerability in several open source projects.

Fix

Golang offers other methods to parse query strings, and developers should use those. For example, the ParseQuery method lets developers consider the returned error:

From the original on oxeye.io

If you still wish to use the vulnerable method, sanitise the raw query so that input containing a semicolon is rejected before the method call. The report notes that there are other ways to masquerade input, for example URL encoding.

To help the community find such vulnerabilities, Oxeye wrote a Semgrep rule that alerts you if your codebase uses the vulnerable method and suggests an auto-fix using the more secure method:

https://semgrep.dev/s/daniel-abeles:golang-http-parameter-smuggling-assignment

All vulnerabilities mentioned in the report were disclosed to their respective vendors and are fixed in the latest versions.

Variants to test

  • Traefik. Traefik is an HTTP reverse proxy and load balancer. One feature blocks specific requests based on query parameters; for example, the following configuration does not forward requests that have the foo parameter:
From the original on oxeye.io

Behind the scenes Traefik uses the vulnerable query string parsing method, and proxying a request to a backend passes both the original request and query string. A request whose foo parameter contains a semicolon bypasses the rule matcher.

  • Skipper. Skipper is an HTTP router and reverse proxy for service composition that also uses vulnerable query parsing. Requests having the foo parameter are rejected with the following configuration:
From the original on oxeye.io

A request with the foo parameter and a trailing semicolon bypasses the rule matcher, so Skipper does not reject it.

  • Any two-service chain with mixed Golang versions. Put a front service on 1.17 or later in front of a backend on an earlier version, and send a parameter that the front service uses for an access decision with a trailing semicolon.
  • Any proxy built on NewSingleHostReverseProxy. Check whether the proxy forwards the raw query string and whether the backend parses semicolons as delimiters.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

A team of security researchers found a bug that affects programs written in a programming language called Go (often written Golang). The bug lets someone sneak a piece of information past a security check, so that a request which should have been refused is quietly let through.

The trick relies on a single character: the semicolon (;). Different versions of Go disagree about what a semicolon means when it appears inside the part of a web address that carries settings. When two Go programs sit one behind the other and run different versions, the front one can fail to see a setting that the back one sees perfectly well. If the front program is the one making the security decision, that decision is made on incomplete information.

The researchers showed the bug in a real product called Harbor, and also found it in two other tools, Traefik and Skipper. The bug was given an official identifier, CVE-2022-2880, and Go's maintainers released a fix. Later the entry was rated HIGH severity with a CVSS score of 7.5.

Before going further, a few words on the building blocks, because the whole story depends on them.

  • A URL (uniform resource locator) is the address you type in a browser, like https://example.com/page. It is the internet's way of naming a thing.
  • An HTTP request is the message a browser (or any program) sends to a server to ask for something. It has a method (like GET or PUT), a path, and often a query string: the part after a ? that carries settings, written as name=value pairs joined by &.
  • A server is the program on the other end that reads the request and answers it.
  • An API (application programming interface) is the set of addresses and rules a service offers so that other programs can talk to it. Think of it as the service's menu: which requests it accepts and what each one does.
  • Parsing means taking a piece of text and working out its structure, the way you might take a sentence and pick out subject, verb and object. URL parsing is doing that with a web address.
  • A reverse proxy is a program that sits in front of other servers and passes requests along to them. Think of a receptionist who takes your request at the front desk and walks it to the right office.
  • A microservice is one small program that does one job, with several of them working together to make a whole product.
  • A container is a packaged bundle of a program and everything it needs to run. A Docker image is the file that a container is built from, and a registry is the online library where images are stored.
  • A CVE is a public catalogue number for a known security flaw, so people can talk about the same bug unambiguously.
  • CVSS is a scoring system that rates how serious a flaw is, from 0 to 10.

With those in hand, the rest of this article walks through how the researchers found the bug, how they proved it in Harbor, and how to fix it.

Context

Oxeye's security research team found a vulnerability in applications built with Go. The flaw lets an attacker get around checks that are based on the settings carried in an HTTP request. The root cause is unsafe URL parsing: different versions of Go disagree about what a semicolon means inside a query string, and a helper that Go provides for building reverse proxies forwards the raw query without parsing it. When two services in a chain run different Go versions, a setting that the front service does not see can reappear at the back service.

The report was published on 28 July 2022. On 10 October 2022, CVE-2022-2880 was assigned to the vulnerability and the Go team patched it in an update. On 23 October 2022, the NVD (the body that maintains the CVE catalogue) updated the entry with a HIGH severity rating and a CVSS score of 7.5.

The case study is Harbor, an open source registry that secures artifacts with policies and role-based access control. Harbor is a CNCF Graduated project and lets you centralise multiple image registries under one roof. It uses the distribution container registry to store and manage Docker images. The feature at the centre of the case is Cross Repository Blob Mount, which saves disk space and network bandwidth when storing or uploading Docker images that point to the same file system layers.

A few of those terms deserve a plain explanation:

  • An artifact is any file a build produces, most often a Docker image.
  • Role-based access control means each user is given a role (viewer, developer, administrator) and the role decides what they may do.
  • A CNCF Graduated project is one that has reached the top maturity level in the Cloud Native Computing Foundation, an industry body that stewards open source infrastructure software.
  • A blob is a chunk of stored data, here a layer of a Docker image. A digest is a long fingerprint computed from the content, used to name a blob uniquely.
  • Cross Repository Blob Mount is a shortcut: if a layer already exists in one repository, another repository can point at the same stored copy instead of uploading it again. That is where the disk and bandwidth savings come from.

Setup

The precondition is a deployment where two Go services sit in a chain and run different versions. The first is a user-facing application on Go 1.17 or later; the second, a backend service, runs on an earlier version.

For the Harbor case, Oxeye looked for deployments with this version discrepancy and found that Bitnami, a company acquired by VMware that holds Helm charts and Docker images for various projects, had this exact setup: its core Harbor microservice runs on Go 1.17, while the Docker registry microservice runs on version 1.15.

The attacker needs an authenticated account. Even the lowest permission level is enough. To complete the exploit, the attacker also needs to know a blob digest hash to mount; the report says this challenge is discussed in the next blog post.

Why does the version gap matter so much? Because the two services are reading the same text with two different rulebooks. The front service, on the newer version, refuses to accept a semicolon in the query and therefore does not see the setting at all. The back service, on the older version, treats the semicolon as an ordinary separator and sees the setting clearly. Neither service is doing anything wrong by its own rules; the problem is that they disagree.

Finding it

URL parsing is normally done according to RFC 3986, a document that describes the components of a URL:

From the original on oxeye.io

The image shows the standard breakdown of a URL into its parts, the reference that URL parsing implementations generally follow.

Every language implements this logic itself: Python has urllib.parse, Go has net/url. Each follows the same guidelines but contains minor differences, and those differences produce parsing inconsistencies on the same input. In everyday terms, two people reading the same address might disagree about whether the flat number is part of the street name.

Go's core team released a patch that fundamentally changed how the language parses URLs. Before version 1.17, Go treated a semicolon inside the query portion of a URL as a valid delimiter, the same way it treats an ampersand. The behaviour comes from the parseQuery method:

From the original on oxeye.io

The image shows the parseQuery method, which treats the semicolon as a valid delimiter.

So a URL like the one below yields two query parameters, name and company, rather than a single name parameter:

From the original on oxeye.io

The image shows the example URL and the two query parameters it yields.

From version 1.17, parseQuery returns an error if the URL query contains a semicolon:

From the original on oxeye.io

The image shows the updated parseQuery method, which returns an error when the query contains a semicolon.

But the fix was incomplete. One of the methods responsible for getting the parsed query string ignores the returned error:

From the original on oxeye.io

The image shows that method, which ignores the returned error. This is the crucial detail: the error exists, but nobody acts on it.

Separately, Go offers a built-in function to proxy HTTP traffic through its httputil/reverseproxy.go module. To create a new reverse proxy it provides the NewSingleHostReverseProxy method:

From the original on oxeye.io

The image shows the NewSingleHostReverseProxy method, which takes the raw query string rather than the parsed one and sends it as is.

Exploitation

Step 1: understand the chain

Consider two Go-based services. The first is user-facing and runs 1.17 or later; the second is a backend on an earlier version. A user makes an HTTP request to the first service with a name query parameter, and the first service decides whether to pass the request through based on that parameter.

From the original on oxeye.io

The image shows the user's request to the first service, which decides whether to pass it through based on the name parameter.

Step 2: append a semicolon

If the user appends a semicolon to the name parameter, the first service ignores its existence when parsing the query string. Instead of making a logic decision based on it, the service forwards the request to the backend. The backend receives the transaction and treats the parameter without the semicolon. Requests containing query parameters that would normally be rejected are therefore smuggled through.

This is the heart of the trick. The gatekeeper cannot see the setting, so it has nothing to object to, and it passes the request on. The backend, reading the same text with the older rulebook, sees the setting and acts on it. The name given to this class of problem is HTTP parameter smuggling: a parameter is hidden from one component and revealed to another.

Step 3: the Harbor blob mount request

Reading the Docker registry V2 API, the researchers found the endpoint that allows a Cross Repository Blob Mount. A request that attempts to mount a blob from a different repository looks like this:

From the original on oxeye.io

The request that attempts to mount a blob from a different repository looks like this:

  • The method and path identify the target repository and the blob being mounted.
  • The query string carries the two settings the endpoint expects, mount and from.
  • The server is expected to check permissions before doing anything.

To mount a blob from a foreign repository, the endpoint expects one URL path parameter, name, which specifies the target repository, and two query parameters:

  • mount: the hash digest of the layer to be mounted
  • from: the foreign repository name that already holds the referenced layer

When Harbor receives such a request it performs two permission validations:

  1. It checks whether the user has push access to the repository in the URL parameter <name>.
  2. It checks whether the user has pull access from the repository in the query parameter <from>.

In everyday terms: before letting you copy a file from someone else's folder into your own, the system checks that you are allowed to write into your folder and that you are allowed to read from theirs. Both checks must pass.

Step 4: send it twice

Oxeye sent the cross-repository blob mount request through Harbor twice: once with a valid from value, and once with the same parameter carrying a trailing semicolon.

The original request was blocked by Harbor's authorization checks:

From the original on oxeye.io

The image shows the original request, blocked due to Harbor authorization checks.

The modified request bypassed those checks, and the response confirms that the blob, received from the registry, mounted successfully:

From the original on oxeye.io

The image shows the modified request, which bypassed Harbor authorization checks; the response confirms the blob mounted successfully.

Root cause

The mistake is a disagreement between two parsers about the same string. In Go before 1.17, parseQuery treats a semicolon in the query as a delimiter, so from=x; is read as the parameter from with value x. From 1.17, parseQuery returns an error on a semicolon, but the method that retrieves the parsed query string ignores that error, so the front service does not see the parameter at all. Meanwhile NewSingleHostReverseProxy forwards the raw query string unchanged, so the backend on the older version parses the semicolon away and sees the parameter as intended.

In Harbor's case, the front microservice on 1.17 does not recognise the from parameter when it carries a trailing semicolon, so the pull-access check on the foreign repository is not applied, while the registry microservice on 1.15 reads the parameter normally and performs the mount. The existing defence, the two permission validations, is bypassed because one of the two inputs it depends on is invisible to the component enforcing it.

A useful comparison: two people are checking a list of names at a door. The first reads the list with a rule that says any name followed by a full stop is not a name at all, so they skip it. The second reads the same list with a rule that says the full stop is just punctuation, so they let the person in. Nobody lied, but the door was opened.

Impact

Under specific deployments, an authenticated user, even with the lowest permission level, can issue a special request to read image layers of restricted projects they do not have access to. The attacker must know a blob digest hash to mount it. More generally, miscreants can smuggle requests containing query parameters that normally would be rejected. During the research, Oxeye found multiple instances of this vulnerability in several open source projects.

The digest requirement is a real obstacle: without knowing the fingerprint of the layer, the attacker cannot ask for it by name. That is why the report points to a follow-up article about obtaining the digest.

Fix

Go offers other methods to parse query strings, and developers should use those. For example, the ParseQuery method lets developers consider the returned error:

From the original on oxeye.io

The image shows the ParseQuery method, which lets developers consider the returned error. The lesson is to check the error and act on it.

If you still wish to use the vulnerable method, sanitise the raw query so that input containing a semicolon is rejected before the method call. The report notes that there are other ways to masquerade input, for example URL encoding.

To help the community find such vulnerabilities, Oxeye wrote a Semgrep rule that alerts you if your codebase uses the vulnerable method and suggests an auto-fix using the more secure method:

https://semgrep.dev/s/daniel-abeles:golang-http-parameter-smuggling-assignment

A Semgrep rule is a pattern that a code-scanning tool looks for across a project, so that a known bad habit is flagged automatically rather than discovered by hand.

All vulnerabilities mentioned in the report were disclosed to their respective vendors and are fixed in the latest versions.

Variants to test

The same disagreement can show up in other products. The report lists these places to look:

  • Traefik. Traefik is an HTTP reverse proxy and load balancer. One feature blocks specific requests based on query parameters; for example, the following configuration does not forward requests that have the foo parameter:
From the original on oxeye.io

Behind the scenes Traefik uses the vulnerable query string parsing method, and proxying a request to a backend passes both the original request and query string. A request whose foo parameter contains a semicolon bypasses the rule matcher.

  • Skipper. Skipper is an HTTP router and reverse proxy for service composition that also uses vulnerable query parsing. Requests having the foo parameter are rejected with the following configuration:
From the original on oxeye.io

A request with the foo parameter and a trailing semicolon bypasses the rule matcher, so Skipper does not reject it.

  • Any two-service chain with mixed Go versions. Put a front service on 1.17 or later in front of a backend on an earlier version, and send a parameter that the front service uses for an access decision with a trailing semicolon.
  • Any proxy built on NewSingleHostReverseProxy. Check whether the proxy forwards the raw query string and whether the backend parses semicolons as delimiters.

Glossary

  • API: the set of addresses and rules a service offers so other programs can talk to it.
  • Artifact: a file produced by a build, such as a Docker image.
  • Backend service: the program further back in a chain that does the actual work after a front service passes a request along.
  • Blob: a chunk of stored data, here a layer of a Docker image.
  • CNCF Graduated project: an open source project that has reached the top maturity level in the Cloud Native Computing Foundation.
  • Container: a packaged bundle of a program and everything it needs to run.
  • Cross Repository Blob Mount: a registry shortcut that lets one repository point at a layer already stored in another, saving disk space and bandwidth.
  • CVE: a public catalogue number for a known security flaw.
  • CVSS: a scoring system that rates the severity of a flaw from 0 to 10.
  • Digest: a long fingerprint computed from a blob's content, used to name it uniquely.
  • Docker image: the file a container is built from.
  • Endpoint: a specific address in an API that accepts a particular kind of request.
  • HTTP parameter smuggling: hiding a request parameter from one component while another component still sees and acts on it.
  • HTTP request: the message a program sends to a server to ask for something, with a method, a path and often a query string.
  • Microservice: one small program that does one job, with several working together to make a product.
  • NVD: the body that maintains the CVE catalogue and its severity ratings.
  • Parsing: taking a piece of text and working out its structure.
  • Query string: the part of a URL after the ? that carries settings as name=value pairs.
  • Registry: an online library where Docker images are stored.
  • Reverse proxy: a program that sits in front of other servers and passes requests along to them.
  • RFC 3986: the document that describes the components of a URL.
  • Role-based access control: giving each user a role that decides what they may do.
  • Semgrep rule: a pattern a code-scanning tool looks for across a project to flag a known bad habit.
  • Server: the program that reads a request and answers it.
  • URL: a web address, the internet's way of naming a thing.
  • URL parsing: working out the structure of a web address.
  • Vulnerability: a flaw in a program that someone can abuse to make it behave in a way its authors did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.