Skip to content

Security: Command Injection via kopen() pipe execution (RCE) #456

Description

@jabir-dev

Security Vulnerability Report

Severity: Critical (CVSS 4.0: 10.0)
CWE: CWE-78 (OS Command Injection)
CVE Request: CAN-2026-2030800 (submitted to MITRE)
Affected Versions: All BWA versions (0 through 0.7.19)

Description

BWA's kopen() function in kopen.c (lines 286-309) accepts filenames starting with < and passes the remainder directly to execl("/bin/sh", "sh", "-c", ...) for shell execution without any input sanitization.

Vulnerable Code

// kopen.c:309
if (!need_shell) {
    argv = cmd2argv(p + 1);
    execvp(argv[0], argv);
} else execl("/bin/sh", "sh", "-c", p + 1, NULL);  // COMMAND INJECTION

Proof of Concept

bwa mem ref.fa "< id > /tmp/pwned.txt; echo ACGT; #"
cat /tmp/pwned.txt  # shows output of 'id' command

Confirmed Impact

  • Arbitrary command execution as the BWA process user
  • Credential theft (environment variables, SSH keys)
  • Arbitrary file read/write/delete
  • Reverse shell capability
  • Tested and confirmed with 7 distinct attack scenarios

Attack Surfaces

  • Bioinformatics pipelines with untrusted FASTQ filenames
  • Galaxy/Nextflow/Snakemake workflows
  • Shared HPC clusters
  • Web-based genomics tools wrapping BWA

Remediation

  1. Remove the < pipe feature, OR
  2. Require explicit opt-in flag (--enable-pipe), OR
  3. Sanitize input by rejecting shell metacharacters

Reporter

jabir-dev (GitHub: https://github.com/jabir-dev)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions