Exposed CGI printenv.pl
A default Apache CGI script, printenv.pl, was left publicly reachable in the /cgi-bin/ directory of a government tax portal. Anyone could open it and read server environment variables, including software versions and absolute installation paths.
medium.com
Published on medium.com
Bug Hunter
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
The target was the e-SPTPD portal (Elektronik Surat Pemberitahuan Pajak Daerah, the electronic regional tax notification system) belonging to a regional government (Pemerintah Kabupaten) whose name is redacted in the write-up. The portal is a public service system, and the researcher was testing it during reconnaissance and vulnerability testing on 15 November 2025.
The issue is not in the application itself but in the web server's default CGI directory. Apache ships a sample CGI script called printenv.pl that, when executed, returns the environment variables of the CGI process. On a correctly configured server this file is either absent or unreachable; here it was still publicly executable at /cgi-bin/printenv.pl, so a plain GET request to it disclosed the server's environment.
The author classifies the issue as Sensitive Information Disclosure (Exposed CGI Script), rates it Medium, and records the outcome as a silent fix: the script was no longer reachable when rechecked, without any reply or confirmation from the affected party.
Setup
No accounts, roles or special tooling are described. The only precondition was network access to the public portal. The researcher found the script while fuzzing directories, then confirmed it by requesting the URL directly in a browser. The exposed software versions recorded in the output were Apache/2.4.48, OpenSSL/1.1.1k and PHP/7.4.20, running on Win64.
Finding it
During directory fuzzing against the e-SPTPD host, the researcher came across a CGI script that was still publicly accessible: the Apache default printenv.pl under /cgi-bin/. A script like this is not part of the application's functionality. It exists as a sample, and when the web server executes it, it prints every environment variable available to the CGI process. Nothing on the target removed the file or blocked access to the directory, so the script ran for any anonymous visitor.
Exploitation
Step 1: Identify the target
The researcher opened the CGI script's URL directly in a browser:
https://e-sptpd.redactedkab.go.id/cgi-bin/printenv.pl
The path is the important part: /cgi-bin/ is the conventional CGI directory, and printenv.pl is the stock Apache sample script. Because the request is an ordinary GET with no parameters, no authentication and no special headers, the only condition for success is that the file exists and the CGI handler is enabled for that directory.

Step 2: Analyse the output
The response body was the script's environment dump. Among the variables, the researcher highlights the following:
SERVER_SOFTWARE="Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/7.4.20"
PHPRC="C:\xampp\php"
MYSQL_HOME="C:\xampp\mysql\bin"
SERVER_SOFTWARE identifies the web server build and the linked OpenSSL and PHP versions. PHPRC and MYSQL_HOME are absolute Windows paths that reveal the installation layout: the stack is an XAMPP installation on C:\, with PHP under C:\xampp\php and MySQL under C:\xampp\mysql\bin. The PATH variable, which the researcher also lists, leaks the directory structure of the PHP, Apache and MySQL installations in the same way.
Beyond those, the dump contained the request's HTTP headers (User-Agent, Accept, Cookie and others) and server configuration variables such as SERVER_ADMIN, SERVER_NAME and SERVER_PORT.

Step 3: Verify the fix
After the report, the affected party appears to have fixed the issue quietly. When the researcher checked again on 16 October 2026, the printenv.pl URL was no longer accessible.
Root cause
The application did not remove or block access to the Apache default script printenv.pl in the /cgi-bin/ directory. When the web server executes it, it returns every environment variable available to the CGI process. The write-up does not describe the server configuration in detail, so why the default file survived deployment and why the CGI directory stayed reachable is not stated; The write-up does not state why the default file survived deployment or why the CGI directory stayed reachable.
Impact
The disclosure gives an attacker a map of the server. The researcher lists four consequences:
- Infrastructure mapping. Knowing the Apache, PHP and OpenSSL versions lets an attacker look for known vulnerabilities in those exact versions and exploit them.
- Information disclosure. Absolute system paths can help with Local File Inclusion (LFI) or Remote Code Execution (RCE) attacks.
- Further reconnaissance. Server configuration and environment variables help an attacker plan more targeted attacks.
- Credential leakage. In some cases environment variables can contain database credentials or sensitive API keys.
These are the researcher's stated possibilities; the write-up does not say that any credential was actually present in this particular dump. The exposure required nothing more than an unauthenticated request to a public URL.
Fix
What was changed: the script became unreachable, confirmed by a recheck on 16 October 2026.
The researcher recommends three steps:
- Remove default scripts. Delete
printenv.pl,test-cgi,printenvand any other unused CGI scripts from/cgi-bin/. - Block
/cgi-bin/. If the CGI directory is not used, deny access to it in the web server configuration. - Disable CGI. If no application needs CGI, turn off the CGI module to reduce the attack surface.
Variants to test
- Other stock CGI samples. Request
/cgi-bin/test-cgi,/cgi-bin/printenvand similar default names on other hosts. A positive result is a response containing environment variables or CGI test output rather than a 404 or 403. - Directory listing on
/cgi-bin/. Request the directory itself. A positive result is a listing that enumerates the scripts present. - Environment leakage through other handlers. Look for scripts or endpoints that echo server-side variables (debug pages, phpinfo-style pages, error pages with stack traces). A positive result is any response exposing paths, versions or configuration values.
- Version fingerprinting from the leak. Compare any disclosed
SERVER_SOFTWAREstring against known vulnerabilities for those exact versions. A positive result is a version with a public advisory that matches the deployed build. - Credential search in the dump. If an environment dump is obtained, check it for database credentials or API keys. A positive result is a secret value in a variable, which turns an information leak into direct access.
What happened, in plain words
A government website that lets people handle a local tax online was running a small leftover file that came with its web server software. That file, when anyone opened it in a browser, printed out a list of the server's internal settings: which software versions it runs, where its programs are installed on the disk, and other details that were never meant to be public. The researcher found the file, opened it, and saw all of that. He reported it, got no reply, and later found the file had quietly been made unreachable. This article walks through the whole thing from zero, assuming you can use a browser and nothing else.
Background: what the target is
The target was the e-SPTPD portal. e-SPTPD stands for Elektronik Surat Pemberitahuan Pajak Daerah, which translates roughly as the electronic regional tax notification system. In everyday terms, it is the online service a regional government (a Pemerintah Kabupaten, meaning a regency government) uses so that local taxpayers can deal with their regional tax paperwork over the web instead of at a counter. The name of the specific regency is redacted in the write-up, so we do not know which one it was.
Because it is a public service portal, anyone on the internet can reach it. That is the whole point of such a site, and it is also why it is worth checking: a public door is a door anyone can try.
The researcher was doing reconnaissance and vulnerability testing on 15 November 2025. Two terms to unpack:
- Reconnaissance (often shortened to recon) is the information-gathering phase. Before trying to find a weakness, you first learn what the target is made of: which pages exist, which software answers, which folders are reachable. Think of it like walking around a building before you try any doors, noting where the windows are and what kind of locks you can see.
- Vulnerability testing is the part where you actually poke at what you found, carefully, to see whether a weakness is real. Recon tells you there is a window; testing tells you whether it is actually open.
The important thing to understand up front is that the problem was not in the tax application itself. It was in the web server underneath it, the software that receives every visitor's request and hands back the right page. That distinction matters later, because it changes who has to fix it and how.
The concept you need first: what a web server and CGI are
When you type a web address into your browser, your browser sends a request across the internet to a web server. The web server is a program running on the organisation's machine whose job is to answer those requests. Most of the time it simply hands back a file, like a page of text or an image. That is the plain, static case.
Sometimes, though, the answer has to be computed rather than fetched. A tax portal has to look up your record, do arithmetic, and build a page just for you. To do that, the web server hands the job to a separate program, waits for that program to produce output, and passes the output back to your browser. The old, standard way of making that handover is called CGI, short for Common Gateway Interface. You can think of CGI as a waiter's hatch between the dining room and the kitchen: the web server takes your order at the hatch, the kitchen program cooks something, and the plate comes back out the same hatch. The folder where those kitchen programs conventionally live is called /cgi-bin/.
Now the crucial part. When the web server starts one of those CGI programs, it does not start it in a vacuum. It passes along a bundle of environment variables: named settings that tell the program about the world it is running in. Things like which folder the program lives in, which software versions are installed, and details of the visitor's request. Environment variables are like the sticky notes taped to a new employee's desk on their first morning: where the coffee is, who to ask for help, which system holds the records. Useful to the employee, and not something you would read out to a stranger at the front desk.
The file at the centre of it: printenv.pl
Apache is one of the most widely used web servers in the world. Like many pieces of software, it ships with a few sample files so that administrators can check that things work. One of those samples is a small script called printenv.pl. Its entire purpose is to print the environment variables it was given. It is a diagnostic toy, a way to confirm that CGI is wired up correctly.
On a properly configured server, this sample is either deleted or made unreachable once setup is finished. Here, it was neither. It was still sitting in /cgi-bin/ and still publicly executable, which means any anonymous visitor could ask the web server to run it and read what it printed.
The author classifies the issue as Sensitive Information Disclosure (Exposed CGI Script) and rates it Medium. Let us take those apart:
- Sensitive Information Disclosure is a whole family of weaknesses where the problem is not that someone can break in, but that the system tells them things it should keep to itself. Nothing is changed or stolen; the system simply talks too much. It is the difference between a burglar forcing a door and a receptionist reading the staff roster to anyone who asks.
- Exposed CGI Script is the specific flavour here: a CGI program that should not be reachable is reachable.
- Medium is a severity rating, a rough label for how much damage the issue could lead to. It sits in the middle: not a trivial cosmetic flaw, not an immediate full takeover either.
The outcome is recorded as a silent fix. That means the problem was repaired, but nobody on the receiving side ever replied or confirmed it. The researcher only knows it was fixed because the file stopped responding when he checked again.
Setup: what was needed
Almost nothing. No account, no login, no special role, no specialised tooling is described in the write-up. The only precondition was ordinary network access to the public portal, which is to say, a working internet connection and a browser.
The researcher found the script while fuzzing directories, then confirmed it by requesting the URL directly in a browser. Fuzzing needs a word of explanation, because it sounds more exotic than it is.
Directory fuzzing means asking a web server for a long list of plausible folder and file names, one after another, and watching which ones answer. You try /admin, /backup, /test, /cgi-bin, and hundreds of others, and you note which ones come back with something other than "not found". It is like walking down a corridor jiggling every door handle instead of guessing which single door is unlocked. Most handles do not move. Occasionally one does, and that is your lead.
That is how the script was found: not by reading the application's code, but by asking the server for a name that happened to exist. The exposed software versions recorded in the output were Apache/2.4.48, OpenSSL/1.1.1k and PHP/7.4.20, running on Win64. We will come back to what each of those is when we read the output.
Finding it
During directory fuzzing against the e-SPTPD host, the researcher came across a CGI script that was still publicly accessible: the Apache default printenv.pl under /cgi-bin/.
It is worth being clear about why this is interesting at all. A script like this is not part of the application's functionality. No taxpayer needs it. It exists purely as a sample, and when the web server executes it, it prints every environment variable available to the CGI process. Nothing on the target removed the file or blocked access to the directory, so the script ran for any anonymous visitor. The organisation had, in effect, left the diagnostic hatch open after the kitchen was built.
Exploitation
Step 1: Identify the target
The researcher opened the CGI script's URL directly in a browser:
https://e-sptpd.redactedkab.go.id/cgi-bin/printenv.pl
Line by line, in plain words:
https://is the secure version of the web's addressing scheme. Thesmeans the traffic between your browser and the server is encrypted, so nobody in between can read it. It says nothing about whether the server is well configured; it only protects the journey.e-sptpd.redactedkab.go.idis the address of the portal. The ending.go.idis the country-code domain for Indonesian government bodies, which is a hint about who runs the site. The middle part is redacted in the write-up, so the exact regency is not disclosed./cgi-bin/is the conventional folder for CGI programs, the waiter's hatch described earlier.printenv.plis the stock Apache sample script. The.plending means it is written in Perl, a programming language that was very common for CGI scripts.
Why this step was taken: having found the name during fuzzing, the researcher wanted to confirm it in the simplest possible way, by visiting it as any member of the public would. The path is the important part. Because the request is an ordinary GET (the normal kind of request your browser makes when you type an address and press Enter) with no parameters, no authentication and no special headers, the only condition for success is that the file exists and the CGI handler is enabled for that directory. There is no trick to it. That is precisely what makes it a finding: no trick was needed.

Step 2: Analyse the output
The response body was the script's environment dump: a plain list of settings, one per line. Among the variables, the researcher highlights the following:
SERVER_SOFTWARE="Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/7.4.20"
PHPRC="C:\xampp\php"
MYSQL_HOME="C:\xampp\mysql\bin"
What each of these means:
SERVER_SOFTWAREis the variable that names the web server build and the other software linked into it. Reading it left to right: Apache/2.4.48 is the web server and its version number. (Win64) says it is the 64-bit build for Windows, so the machine is a Windows server, not Linux. OpenSSL/1.1.1k is the library that handles encryption, the same kind of encryption that makeshttps://work. PHP/7.4.20 is the programming language most web applications are written in, and this is the version installed. In one line, a stranger now knows exactly which three pieces of software to look up.PHPRCtells PHP where its configuration lives. The valueC:\xampp\phpis an absolute Windows path: the double backslashes are just how a backslash is written inside a quoted string, so the real path isC:\xampp\php. That reveals both the drive and the folder layout.MYSQL_HOMEdoes the same job for MySQL, the database software that stores the actual records. Its value points atC:\xampp\mysql\bin.
Put together, PHPRC and MYSQL_HOME are absolute Windows paths that reveal the installation layout: the stack is an XAMPP installation on C:\, with PHP under C:\xampp\php and MySQL under C:\xampp\mysql\bin. XAMPP is a well-known free package that bundles Apache, PHP and MySQL together so that people can set up a web server quickly on their own machine. It is popular for development and testing.
The PATH variable, which the researcher also lists, leaks the directory structure of the PHP, Apache and MySQL installations in the same way. PATH is the list of folders the operating system searches when it is told to run a program by name; it is the equivalent of the list of places you look for your keys before admitting they are lost. Because it names those folders in full, it hands over the same map.
Beyond those, the dump contained the request's HTTP headers (User-Agent, Accept, Cookie and others) and server configuration variables such as SERVER_ADMIN, SERVER_NAME and SERVER_PORT. A quick word on each, since they appear in the write-up:
- HTTP headers are the small labelled lines that travel alongside every web request and response, carrying housekeeping details rather than the page itself. Think of them as the information written on the outside of an envelope: who sent it, what is inside, how it should be handled.
- User-Agent is the header where your browser says what it is, for example which browser and version. Accept is where it says what kinds of content it can handle. Cookie is where it carries small pieces of data the site previously stored in your browser, often including a session identifier that proves who you are. That last one is why cookies matter: a cookie can act like a wristband at an event, and anyone who reads your wristband number may be able to act as you.
- SERVER_ADMIN is the contact address configured for the server's administrator. SERVER_NAME is the hostname the server knows itself by. SERVER_PORT is the numbered channel the service listens on, the way a building has a street number and then a flat number.

Step 3: Verify the fix
After the report, the affected party appears to have fixed the issue quietly. When the researcher checked again on 16 October 2026, the printenv.pl URL was no longer accessible.
Why this step was taken: a finding is only useful if you can say what its current state is. Checking again turns "I reported this" into "this is closed now", which is what makes the write-up a complete record rather than an open question.
Root cause
The application did not remove or block access to the Apache default script printenv.pl in the /cgi-bin/ directory. When the web server executes it, it returns every environment variable available to the CGI process.
The write-up does not describe the server configuration in detail, so why the default file survived deployment and why the CGI directory stayed reachable is not stated. The write-up does not state why the default file survived deployment or why the CGI directory stayed reachable. This is a very common pattern. Software arrives with sample files and default settings that are fine on a developer's laptop and wrong on a public server, and the step of cleaning them up is easy to forget because nothing breaks when you skip it.
Impact
The disclosure gives an attacker a map of the server. The researcher lists four consequences:
- Infrastructure mapping. Knowing the Apache, PHP and OpenSSL versions lets an attacker look for known vulnerabilities in those exact versions and exploit them. Software versions are like a model number on a lock. Most locks are fine, but if a particular model is known to be pickable, the number on the front tells a burglar where to start.
- Information disclosure. Absolute system paths can help with Local File Inclusion (LFI) or Remote Code Execution (RCE) attacks. Two terms: Local File Inclusion is a weakness where an application can be tricked into loading a file from its own disk that it should not load, and knowing the exact folder layout makes that far easier to aim. Remote Code Execution is the severe end point where an attacker gets the server to run their own commands; again, knowing where things live helps.
- Further reconnaissance. Server configuration and environment variables help an attacker plan more targeted attacks. The first leak makes the next step cheaper.
- Credential leakage. In some cases environment variables can contain database credentials or sensitive API keys. A credential is a username and password pair, and an API key is a long secret string that lets a program talk to another service without a password, rather like a spare key kept under the mat for the cleaner.
These are the researcher's stated possibilities. That distinction is worth holding on to: the risk is real and the categories are real, but the specific dump described here is not reported to have contained a secret. The exposure required nothing more than an unauthenticated request to a public URL, which is to say, no login and no special knowledge beyond the file's name.
Fix
What was changed: the script became unreachable, confirmed by a recheck on 16 October 2026.
The researcher recommends three steps:
- Remove default scripts. Delete
printenv.pl,test-cgi,printenvand any other unused CGI scripts from/cgi-bin/. The simplest fix is to take away the thing that should never have been there. - Block
/cgi-bin/. If the CGI directory is not used, deny access to it in the web server configuration. This is the belt-and-braces version: even if a file is left behind, nobody can reach the folder to run it. - Disable CGI. If no application needs CGI, turn off the CGI module to reduce the attack surface. Attack surface means the total set of things an outsider can interact with. Every feature you switch off is one fewer thing that can be misconfigured.
Variants to test
If you want to look for the same class of problem elsewhere, these are the directions the write-up points to. Each one names what a positive result looks like, so you know when you have something.
- Other stock CGI samples. Request
/cgi-bin/test-cgi,/cgi-bin/printenvand similar default names on other hosts. A positive result is a response containing environment variables or CGI test output rather than a 404 or 403. Those two numbers are HTTP status codes: 404 means "not found" and 403 means "forbidden". Either is a good answer here; a page full of settings is not. - Directory listing on
/cgi-bin/. Request the directory itself. A positive result is a listing that enumerates the scripts present. Many servers will show a folder's contents if no index page exists, which turns a guess into a menu. - Environment leakage through other handlers. Look for scripts or endpoints that echo server-side variables (debug pages, phpinfo-style pages, error pages with stack traces). A positive result is any response exposing paths, versions or configuration values. A stack trace is the debugging output a program prints when it crashes, which often names internal files and folders.
- Version fingerprinting from the leak. Compare any disclosed
SERVER_SOFTWAREstring against known vulnerabilities for those exact versions. A positive result is a version with a public advisory that matches the deployed build. Fingerprinting is the act of identifying exactly what software and version is running, and an advisory is the public notice that a particular version has a known flaw. - Credential search in the dump. If an environment dump is obtained, check it for database credentials or API keys. A positive result is a secret value in a variable, which turns an information leak into direct access.
Timeline
The write-up records the sequence as follows:
- 15 November 2025: found the vulnerability and verified the proof of concept.
- 15 November 2025: reported the vulnerability to the affected party.
- Up to 16 October 2026: no reply or confirmation from the affected party.
- 16 October 2026: checked again; the
printenv.plscript was no longer accessible. The write-up was published as portfolio documentation.
A proof of concept, or PoC, is the smallest demonstration that a weakness is real: here, simply loading the URL and seeing the output. It is the difference between saying a door is unlocked and opening it to show someone.
Closing thoughts
This kind of issue is a reminder that the sample files that come with web server software are easy to forget, and that a forgotten file can be a way in for an attacker. Even though the report received no official reply and was fixed quietly, the researcher still credits the affected party for closing the gap.
For anyone hunting bugs, a silent fix is a normal outcome. What matters is that the vulnerability can no longer be exploited. Documentation like this is still worth writing, because it shows what you found and how you found it.
Glossary
- Advisory: a public notice that a particular piece of software, at a particular version, has a known flaw.
- API key: a long secret string that lets one program talk to another service without a username and password.
- Apache: one of the most widely used web server programs.
- Attack surface: the total set of things an outsider can interact with on a system; fewer features means a smaller surface.
- CGI (Common Gateway Interface): the standard way a web server hands a request to a separate program and passes that program's output back to the visitor.
- Cookie: a small piece of data a site stores in your browser and receives back on later requests, often used to remember who you are.
- Credential: a username and password pair used to prove identity.
- Directory fuzzing: asking a web server for a long list of plausible folder and file names to see which ones exist.
- Environment variables: named settings passed to a program when it starts, describing the world it runs in, such as paths and software versions.
- Fingerprinting: identifying exactly which software and which version is running on a system.
- GET: the ordinary kind of web request a browser makes when you type an address and press Enter.
- HTTP headers: small labelled lines sent alongside a web request or response, carrying housekeeping details rather than the page content.
- Local File Inclusion (LFI): a weakness where an application can be tricked into loading a file from its own disk that it should not load.
- Medium: a middle severity rating, between a trivial flaw and an immediate full takeover.
- MySQL: database software that stores records for web applications.
- OpenSSL: the library that handles encryption, including the encryption behind
https://. - PATH: the list of folders the operating system searches when told to run a program by name.
- PHP: a programming language commonly used to build web applications.
- Proof of concept (PoC): the smallest demonstration that a weakness is real.
- Reconnaissance (recon): the information-gathering phase before testing, learning what the target is made of.
- Remote Code Execution (RCE): a severe weakness where an attacker gets the server to run their own commands.
- Sensitive Information Disclosure: a family of weaknesses where a system reveals information it should keep private, without anything being changed or stolen.
- Silent fix: a problem that was repaired without any reply or confirmation from the affected party.
- Stack trace: debugging output a program prints when it crashes, often naming internal files and folders.
- User-Agent: the header in which your browser states what browser and version it is.
- Vulnerability testing: deliberately probing a target to see whether a suspected weakness is real.
- Web server: the program that receives visitors' requests and returns the right pages or content.
- XAMPP: a free package that bundles Apache, PHP and MySQL together for quick setup of a web server.
- 403: the HTTP status code meaning "forbidden".
- 404: the HTTP status code meaning "not found".