The Tale of a Command Injection by Changing the Logo
An admin panel was protected by default credentials, and its logo upload feature passed the uploaded file's name to a shell command without sanitisation. An attacker could run arbitrary commands on the server.
Hello my friends, in this write-up, I will explain how I found four P1 and two P2 bugs and showed multiple attack scenarios.
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
This is a write-up of a bug bounty hunt on a wide-scope program. The researcher describes finding four P1 and two P2 bugs and showing multiple attack scenarios. The target was an admin login page, written in PHP according to Wappalyzer, reached through an IP that Shodan attributed to the company's ASN. The feature at the centre of the story is a logo and photo management panel: an admin can change the site's logo and images through a changelogo.php script, and the panel ships with a Chinese-language .doc recipe explaining how to use it.
Setup
The researcher worked from the command line and from a Burp proxy, with FFUF for content discovery and Wappalyzer for fingerprinting. No accounts were provisioned: the entry point was a default credential pair found on a directory-protected admin area. The precondition for the whole chain is that the admin panel is reachable from the internet and that its upload script is exposed.
Finding it
Recon
The starting point for wide-scope programs is the company's ASNs and CIDRs, which lead to the IPs the company owns. Those IPs help later: against a site behind a CDN they can reveal the origin, or the PTR records can point at domains served on the IP, or a port scan can be run on the IP itself. Any service found that way has to be verified as belonging to the company, and the security team can help with that verification.
The researcher looked the company up on https://bgpview.io and got its ASNs. Live IPs in an ASN can be enumerated manually:
whois -h whois.radb.net -- '-i origin AS123' | grep -Eo "([0-9.]+){4}/[0-9]+" | uniq | mapcidr -silent | httpxasn:AS123
The whois call fetches the ASN owner's information, grep extracts the CIDRs from the output, uniq removes duplicates, mapcidr maps and converts the IPs, and httpx performs service discovery. Ports can be specified for httpx.
The easier route is Shodan with:
asn:AS123
Shodan follows almost the same flow, but the CLI method is more complete: a service may have gone live on a new IP that Shodan has not yet requested. Shodan's ASN search is not available on free accounts; a membership account is required.
Shodan returned about 200 IPs. Among them the researcher picked a page that looked like an admin panel.
The admin panel
The target was an admin login page. SQL injection on the login form was tried first and did not work. Because the target had a document root, directory and file fuzzing followed with FFUF. After a few minutes a 401 came back on:
http://target.com/Config/
The page was opened in the browser and admin:admin was tried on the login prompt. It worked. The reasoning recorded is that a system protecting such an important place with such a user and password must work properly, and probably the whole table of credentials would be found.
Further inspection found folders named js, css, images and data. Nothing in them was interesting until a rar file in the images folder stood out. Inside it was a .doc file: a recipe in Chinese for the admin to change the site's logo and photos. That document pointed at changelogo.php.
The upload script
Requesting changelogo.php in the browser returned the whole response but nothing visible. Checking the render tab in Burp showed the page did not load. In the browser the researcher was redirected to index.php, but the Burp response contained code showing a file upload form. A gif was uploaded to see how the server behaved; it was accepted and ended up in the images folder without requiring any access.
A shell upload was attempted and failed. Only .png and .gif were accepted, so the extension was a dead end. The last idea was to put payloads into the filename field, testing RCE, SQL and SSTI:
filename="PAYLOADS.ext"
Because the application was written in PHP, SQL injection payloads were tried first; they did not work. Then RCE payloads were tried and one worked:
filename="test||sleep 30 ||.gif"
The || sequences chain the injected sleep 30 into whatever command the server builds around the filename.
Finally the researcher searched for the title of this panel across all the IPs collected during recon. In the same IP range another panel with the exact same specifications was found, and it had the same vulnerability.
Exploitation
Step 1: enumerate the ASN and pick a target
- Look up the company on bgpview.io to get its ASNs.
- Enumerate live IPs with the
whois/mapcidr/httpxpipeline, or with the Shodan queryasn:AS123. - From roughly 200 IPs, select a page that resembles an admin panel.
Step 2: get into the admin area
- Fuzz the document root with FFUF.
- Find
http://target.com/Config/returning401. - Open it in the browser and authenticate with
admin:admin.
Step 3: find the upload feature
- Browse the discovered folders (
js,css,images,data). - Extract the
rarfile fromimagesand read the.docinside it, which documentschangelogo.php. - Request
changelogo.php. The browser redirects toindex.php, but the Burp response contains the upload form.
Step 4: probe the upload
- Upload a
gif. It is accepted and stored inimageswith no access requirement. - Try a shell. It fails: only
.pngand.gifare accepted. - Move the payload into the
filenamefield, starting from the templatefilename="PAYLOADS.ext". - SQL injection payloads fail. The RCE payload
filename="test||sleep 30 ||.gif"succeeds, confirmed by the delay.
Step 5: find the second instance
Search for the panel's title across the recon IP list. Another panel with identical specifications sits in the same IP range and carries the same vulnerability.
Root cause
The upload script appears to use the client-supplied filename in a way that lets shell metacharacters run commands, as the || payload in filename="test||sleep 30 ||.gif" demonstrated. The upload accepted only .png and .gif, but that did not stop the injection through the filename. The admin area was additionally protected only by the default admin:admin credential, which gave the researcher access to the feature in the first place. The exact code is not shown in the report, so the precise command being built is not stated.
Impact
An attacker who reaches the panel can execute operating system commands on the server, as demonstrated by the sleep delay. The report frames this as remote code execution, among four P1 and two P2 bugs found overall. The same flaw exists on a second panel in the same IP range. The report does not describe what was done with the execution beyond the timing test, nor which data or systems were reachable from the host.
Fix
The report does not say what was changed. The obvious remediation, given the root cause, is to stop passing the client filename into a shell command: generate a server-side name, or escape and validate the value before use, and replace the default admin:admin credential on the panel.
Variants to test
- Filename fields on upload endpoints. Submit
filename="x||sleep 30 ||.gif"and watch for a delay. A positive result is a response that arrives about 30 seconds late while the file is otherwise handled normally. - Other shell metacharacters in the same field. Try
;,&, backticks and$()around a timing command. A positive result is the same delay or a command output reflected in the response. - Extension allowlists as a false sense of safety. Where only
.pngand.gifare accepted, keep the allowed extension and put the payload in the name, as here. A positive result is execution despite the file type being permitted. - Default credentials on directory-protected admin paths. Fuzz for
401responses on paths such as/Config/and tryadmin:admin. A positive result is access to the protected area after enteringadmin:admin. - Documentation left in web-accessible archives. Look inside
raranddocfiles inimagesand similar folders for internal instructions naming scripts. A positive result is a script name that is reachable and undocumented elsewhere. - Panel titles across a recon IP list. Search the title of a discovered panel across all IPs from the ASN enumeration. A positive result is a second instance with the same software and the same flaw.
Get the Medium app


What happened, in plain words
A security researcher was hunting for bugs on a company's systems, as part of a bug bounty programme. In a bug bounty, a company invites outside people to look for security problems in its systems and pays them for reporting what they find. This researcher found several serious problems, which the report describes as four P1 and two P2 bugs, and showed several ways an attacker could have used them.
The story goes like this. The researcher first worked out which blocks of internet addresses belonged to the company. Then, using a search engine for internet-connected devices called Shodan, they picked one address that looked like an admin login page. The folder returned a 401, and the username and password admin worked on the login page. That got them in. Inside, they found a folder of images that contained a compressed archive file (a rar file). Inside the archive was a Word document, written in Chinese, explaining to the site's administrator how to change the site's logo and photos. That document named a script, changelogo.php, which handles logo uploads.
The upload script only accepted image files with certain extensions, so uploading a malicious program did not work. But the script also took the name of the uploaded file from the person uploading it, and special characters in that name were executed on the server. By putting special characters into the filename, the researcher made the server run a command of their choosing. They proved it with a payload that makes the server run sleep 30. That is called command injection, and because the command runs on the remote server, it is also called remote code execution (RCE).
Finally, they searched for the title of this admin panel across all the addresses they had collected, and found a second panel with the same setup and the same flaw.
Below, each step is explained from scratch, including the tools and the jargon.
Recon
Recon, short for reconnaissance, is the information-gathering phase. Before touching anything, you work out what belongs to the company and where it lives on the internet. Think of it like casing a building before trying the doors: you want a map first.
A company on the internet owns blocks of numeric addresses, called IP addresses. Every device or server on the internet has one, a bit like a postal address. Those blocks are grouped into something called an Autonomous System, or AS, and each AS has a number, the ASN (Autonomous System Number). If you know a company's ASN, you can find all the address blocks it owns, written as CIDRs. A CIDR is just a compact way of writing a range of addresses, for example a whole neighbourhood of addresses in one short notation.
Why bother? Because those addresses can lead you to things the company may not advertise. If a website sits behind a CDN (a content delivery network, a service that sits in front of a site and serves it from many locations), the company's own addresses may reveal the original server behind the CDN. Or the PTR records, which are the internet's reverse phone book, mapping an address back to a domain name, can tell you which domains are served from an address. Or you can scan the address for open ports. A port is a numbered doorway on a server; different services listen on different doorways. Any service you find this way must be confirmed as belonging to the company, and the report notes the security team can help with that confirmation.
The researcher started by looking up the company's name on https://bgpview.io, a site that shows which ASNs and address blocks belong to whom. That gave the company's ASNs. Then they enumerated the live addresses inside an ASN. The report gives a manual command for this:
whois -h whois.radb.net -- '-i origin AS123' | grep -Eo "([0-9.]+){4}/[0-9]+" | uniq | mapcidr -silent | httpxasn:AS123
Line by line, in plain words:
whois -h whois.radb.net -- '-i origin AS123'asks a public database (a whois server) for information about the owner of the ASNAS123.AS123is a placeholder for the real number. The-hpart says which server to ask, and-i originasks for records originating from that ASN.- The vertical bar
|is a pipe. It takes the output of the command on its left and feeds it as input to the command on its right, like passing a bucket along a line. grep -Eo "([0-9.]+){4}/[0-9]+"searches that output for anything shaped like a CIDR (four groups of digits and dots, a slash, then more digits) and prints only the matching pieces.grepis a text search tool.uniqremoves duplicate lines, so the same range is not listed twice.mapcidr -silentis a tool from ProjectDiscovery that expands and converts those ranges into individual addresses.-silentkeeps its chatter out of the output.httpxasn:AS123runshttpx, a tool that probes addresses to see which ones answer with a web service. Theasn:AS123part tells it to work on that ASN's addresses. The report notes you can also specify ports forhttpx.
The easier route is Shodan, a search engine that indexes internet-connected devices and services. You give it a search query:
asn:AS123
This asks Shodan for everything it has indexed inside that ASN. Shodan follows almost the same flow for you, but the command-line method is more complete: a service may have gone live on a new address that Shodan has not yet sent a request to, so Shodan would not know about it. The report adds a note that Shodan's ASN search is not available on free accounts; you need a membership account.
Shodan returned about 200 addresses. Among them, the researcher picked a page that looked like an admin panel, meaning the control area where a site's staff log in to manage things.
Vulnerability Discovery
The chosen target was an admin login page. The researcher checked it with Wappalyzer, a browser extension that guesses which technologies a website is built with, and saw it was written in PHP. PHP is a popular programming language for building websites.
The first idea was SQL injection on the login form. SQL is the language databases speak, and SQL injection means slipping database instructions into a form field so the site runs them. It did not work here.
Next, because the target had a document root (the top folder from which the web server serves the site's files), the researcher fuzzed for directories and files. Fuzzing means automatically trying a long list of common names, like /admin, /backup or /config, and watching which ones exist. The tool used was FFUF.
After a few minutes, FFUF got a 401 response code on this route:
http://target.com/Config/
A response code is the short number a web server sends back with every answer. 200 means fine, 404 means not found, and 401 means "you are not allowed in until you prove who you are". So this folder existed and was locked.
The researcher opened that page in the browser, got a login prompt, and tried the username admin with the password admin. It worked. This is a default credential: a username and password pair that ships with a system and is often never changed. The report records the reasoning that a system protecting such an important place with such a user and password must work properly, and probably the whole table of credentials would be found.
Looking around further, the researcher found several folders named js, css, images and data. js and css hold the site's code and styling, images holds pictures, and data presumably holds data files. Nothing in them was interesting until a rar file in the images folder stood out. A rar file is a compressed archive, like a zip file: one file that holds other files inside it.
Inside the archive was a .doc file, a Word document. It was a recipe in Chinese for the admin to use when changing the site's logo and photos. That document pointed at a file called changelogo.php. This is a classic leak: internal instructions left in a publicly reachable folder, naming a script that is not linked anywhere else.
The upload script
The researcher requested changelogo.php in the browser. The whole response came back, but nothing was visible on the page. Checking the render tab in Burp showed the page did not load. Burp is short for Burp Suite, a tool that sits between your browser and the server and lets you read and edit every request and response. Its render tab shows what the browser would display for a response.
In the browser, the researcher was redirected to index.php, the site's front page. A redirect is the server telling the browser "go somewhere else instead". But when the request was checked in Burp, the response contained code showing a file upload form. In other words, the browser was being bounced away, but the server was still handing back the upload page to anyone who looked at the raw response.
So there was a file upload feature. The next step was to upload a gif file, a common image format, to see how the server behaved. It was accepted and ended up in the images folder without requiring any access at all. That means anyone who knew the file's address could fetch it.
A shell upload was attempted and failed. A shell, in this context, is a small program that, if the server runs it, gives the attacker a way to run commands on the server. It failed because only .png and .gif files were accepted, so changing the file extension was a dead end.
The last idea was to put payloads into the filename field. A payload is the piece of malicious input you send. The filename field is the part of the upload request that carries the name of the file being uploaded. The researcher tested RCE, SQL and SSTI payloads there. SSTI stands for server-side template injection, a flaw where user input is treated as part of a template the server fills in. The template used was:
filename="PAYLOADS.ext"
This is not a real request, just a sketch: the word PAYLOADS marks where the test input goes, and .ext marks where the file extension goes. The point is that the name of the file, not its contents, is now the thing being attacked.
Because the application was written in PHP, SQL injection payloads were tried first. They did not work. Then RCE payloads were tried, and one worked:
filename="test||sleep 30 ||.gif"
Here is what each part does:
filename=is the field name in the upload request."teststarts the filename with the wordtest.||is a shell operator. In a command line,||means "run the command on the right only if the command on the left fails". The shell is the program that reads and runs commands on a server.sleep 30is a command that does nothing for 30 seconds. It is a safe way to prove that a command ran: if the server takes 30 seconds longer to answer, your command executed.||.gif"closes the injected command and keeps the.gifextension so the upload's file type check is still satisfied.
The || sequences chain the injected sleep 30 into whatever command the server builds around the filename. In plain terms: the server took the name the researcher supplied, glued it into a command it ran, and the researcher's special characters broke out of the intended command and ran their own.
Finally, the researcher searched for the title of this panel across all the addresses collected during recon. In the same address range, another panel with the exact same specifications was found, and it had the same vulnerability. Searching a panel's title across a list of addresses is a quick way to find other copies of the same software.
Report
The researcher reported all of the findings immediately, and after a few hours the reports were triaged. Triaged means the company's security team looked at them, confirmed they were real, and put them into their workflow.
Exploitation
Step 1: enumerate the ASN and pick a target
- Look up the company on bgpview.io to get its ASNs.
- Enumerate live addresses with the
whois/mapcidr/httpxpipeline, or with the Shodan queryasn:AS123. - From roughly 200 addresses, select a page that resembles an admin panel.
Step 2: get into the admin area
- Fuzz the document root with FFUF.
- Find
http://target.com/Config/returning401. - Open it in the browser and authenticate with
admin:admin.
Step 3: find the upload feature
- Browse the discovered folders (
js,css,images,data). - Extract the
rarfile fromimagesand read the.docinside it, which documentschangelogo.php. - Request
changelogo.php. The browser redirects toindex.php, but the Burp response contains the upload form.
Step 4: probe the upload
- Upload a
gif. It is accepted and stored inimageswith no access requirement. - Try a shell. It fails: only
.pngand.gifare accepted. - Move the payload into the
filenamefield, starting from the templatefilename="PAYLOADS.ext". - SQL injection payloads fail. The RCE payload
filename="test||sleep 30 ||.gif"succeeds, confirmed by the delay.
Step 5: find the second instance
Search for the panel's title across the recon address list. Another panel with identical specifications sits in the same address range and carries the same vulnerability.
Root cause
The upload script appears to use the client-supplied filename in a way that lets shell metacharacters run commands, as the || payload in filename="test||sleep 30 ||.gif" demonstrated. Sanitising means cleaning input so that special characters cannot do anything unexpected. The upload accepted only .png and .gif, but that did not stop the injection through the filename. The admin area was additionally protected only by the default admin:admin credential, which gave the researcher access to the feature in the first place. The exact code is not shown in the report, so the precise command being built is not stated.
Impact
An attacker who reaches the panel can execute operating system commands on the server, as demonstrated by the sleep delay. The report frames this as remote code execution, among four P1 and two P2 bugs found overall. P1 and P2 are severity labels: P1 is the most serious, P2 the next level down. The same flaw exists on a second panel in the same address range. The report does not describe what was done with the execution beyond the timing test, nor which data or systems were reachable from the host.
Fix
The report does not say what was changed. The obvious remediation, given the root cause, is to stop passing the client filename into a shell command: generate a server-side name, or escape and validate the value before use, and replace the default admin:admin credential on the panel.
Variants to test
These are the same kinds of tests, written so you can try them on systems you are allowed to test.
- Filename fields on upload endpoints. Submit
filename="x||sleep 30 ||.gif"and watch for a delay. A positive result is a response that arrives about 30 seconds late while the file is otherwise handled normally. - Other shell metacharacters in the same field. Try
;,&, backticks and$()around a timing command. A positive result is the same delay or a command output reflected in the response. - Extension allowlists as a false sense of safety. Where only
.pngand.gifare accepted, keep the allowed extension and put the payload in the name, as here. A positive result is execution despite the file type being permitted. - Default credentials on directory-protected admin paths. Fuzz for
401responses on paths such as/Config/and tryadmin:admin. A positive result is access to the protected area after enteringadmin:admin. - Documentation left in web-accessible archives. Look inside
raranddocfiles inimagesand similar folders for internal instructions naming scripts. A positive result is a script name that is reachable and undocumented elsewhere. - Panel titles across a recon address list. Search the title of a discovered panel across all addresses from the ASN enumeration. A positive result is a second instance with the same software and the same flaw.
Get the Medium app


Glossary
- ASN (Autonomous System Number): a number that identifies a block of internet addresses owned by one organisation.
- AS (Autonomous System): the collection of address blocks and routing that belongs to one organisation.
- CIDR: a compact way of writing a range of IP addresses, such as a whole neighbourhood in one short notation.
- IP address: the numeric address of a device or server on the internet.
- PTR record: the internet's reverse phone book, mapping an address back to a domain name.
- Port: a numbered doorway on a server; different services listen on different doorways.
- CDN (content delivery network): a service that sits in front of a website and serves it from many locations.
- Shodan: a search engine that indexes internet-connected devices and services.
- bgpview.io: a website that shows which ASNs and address blocks belong to which organisation.
- whois: a public database and command for looking up who owns a domain or address block.
- grep: a command-line tool that searches text for a pattern.
- uniq: a command-line tool that removes duplicate lines.
- mapcidr: a tool that expands and converts address ranges.
- httpx: a tool that probes addresses to see which ones answer with a web service.
- Admin panel: the control area where a site's staff log in to manage things.
- Wappalyzer: a browser extension that guesses which technologies a website is built with.
- PHP: a popular programming language for building websites.
- SQL: the language databases speak.
- SQL injection: slipping database instructions into a form field so the site runs them.
- Document root: the top folder from which the web server serves the site's files.
- Fuzzing: automatically trying a long list of common names and watching which ones exist.
- FFUF: a tool for fuzzing directories and files on a website.
- Response code: the short number a web server sends back with every answer, such as
200,401or404. - 401: the response code meaning "you are not allowed in until you prove who you are".
- Default credential: a username and password pair that ships with a system and is often never changed.
- rar file: a compressed archive, like a zip file, that holds other files inside it.
- Burp Suite: a tool that sits between your browser and the server and lets you read and edit every request and response.
- Render tab: the part of Burp that shows what the browser would display for a response.
- Redirect: the server telling the browser to go somewhere else instead.
- File upload form: the part of a web page that lets you send a file to the server.
- Shell: a small program that, if the server runs it, gives the attacker a way to run commands on the server.
- Payload: the piece of malicious input you send.
filenamefield: the part of an upload request that carries the name of the file being uploaded.- RCE (remote code execution): making a remote server run code or commands of your choosing.
- SSTI (server-side template injection): a flaw where user input is treated as part of a template the server fills in.
- Shell: the program that reads and runs commands on a server.
||: a shell operator meaning "run the command on the right only if the command on the left fails".sleep: a command that does nothing for a given number of seconds, used to prove a command ran.- Command injection: making a program run extra commands by slipping special characters into input it passes to the shell.
- Sanitising: cleaning input so that special characters cannot do anything unexpected.
- Triaged: the company's security team looked at a report, confirmed it was real, and put it into their workflow.
- P1 / P2: severity labels, where P1 is the most serious and P2 the next level down.
- Bug bounty: a programme where a company invites outside people to look for security problems and pays them for reporting what they find.