<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cpe:2.3:a:postgresql:postgresql:*:*:*:*:*:*:*:* - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/cpes/cpe2.3apostgresqlpostgresql/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Fri, 31 Jul 2026 19:10:28 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/cpes/cpe2.3apostgresqlpostgresql/feed.xml" rel="self" type="application/rss+xml"/><item><title>PostgreSQL COPY PROGRAM Command Execution</title><link>https://feed.craftedsignal.io/briefs/2026-07-postgresql-copy-program/</link><pubDate>Fri, 31 Jul 2026 19:10:28 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-07-postgresql-copy-program/</guid><description>The PostgreSQL 'COPY ... PROGRAM' feature enables users with elevated privileges to execute arbitrary operating-system commands, a technique frequently abused by attackers to deploy cryptominers or establish persistence.</description><content:encoded><![CDATA[<p>The PostgreSQL database management system supports the <code>COPY ... FROM PROGRAM</code> and <code>COPY ... TO PROGRAM</code> SQL commands, which allow the database to interact directly with the underlying host operating system. While intended for administrative data-processing tasks such as importing or exporting files, this functionality provides an avenue for command execution when accessed by a superuser or a role possessing the <code>pg_execute_server_program</code> privilege.</p>
<p>Threat actors who successfully obtain privileged database credentials often exploit this feature to bypass typical application-layer restrictions. By initiating a <code>COPY</code> statement containing the <code>PROGRAM</code> keyword, attackers can spawn shells (e.g., <code>bash</code>, <code>sh</code>), execute downloaders (<code>curl</code>, <code>wget</code>), or run malicious payloads like cryptominers directly within the security context of the PostgreSQL service account. This technique is well-documented in various post-compromise scenarios, including widespread automated cryptomining campaigns that target exposed or weakly protected database instances. Defenders should monitor database query traffic for the presence of the <code>PROGRAM</code> keyword within <code>COPY</code> statements to detect unauthorized process execution.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains access to the database using compromised or brute-forced superuser credentials.</li>
<li>The attacker identifies the database as a target for persistence or resource exploitation (e.g., cryptomining).</li>
<li>The attacker issues a <code>COPY ... FROM PROGRAM</code> or <code>COPY ... TO PROGRAM</code> SQL statement via an active database session.</li>
<li>The PostgreSQL process engine parses the <code>PROGRAM</code> keyword and invokes the specified command through an OS shell.</li>
<li>The OS shell executes the attacker's payload (e.g., a shell script or binary) using the privileges of the <code>postgres</code> service account.</li>
<li>The payload performs subsequent malicious actions, such as establishing a reverse shell, downloading additional malware, or initiating cryptomining processes.</li>
<li>The attacker maintains persistence by leveraging the shell access to install backdoors or scheduled tasks on the underlying host.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation allows for arbitrary code execution on the database server, leading to potential data exfiltration, ransomware deployment, or long-term resource hijacking for cryptomining. These campaigns can impact any organization running PostgreSQL where database access controls are insufficient or where the <code>pg_execute_server_program</code> privilege is assigned to non-administrative service accounts.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Monitor network query logs for any <code>COPY</code> SQL statement containing the <code>PROGRAM</code> keyword using the provided Sigma rule.</li>
<li>Audit database roles to ensure that <code>pg_execute_server_program</code> privileges are restricted strictly to authorized administrative accounts.</li>
<li>Implement endpoint process monitoring to detect the PostgreSQL service account spawning unauthorized child processes such as <code>sh</code>, <code>bash</code>, <code>curl</code>, <code>wget</code>, or cryptomining binaries.</li>
<li>Review PostgreSQL audit logs and network traffic for suspicious database activity, including unusual enumeration or unexpected queries following successful authentication.</li>
<li>Deploy the Sigma rule below to detect potentially malicious <code>COPY</code> statements in network telemetry.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>postgresql</category><category>execution</category><category>network-security</category></item></channel></rss>