Summary
flatpak-builder may execute a Git hook from a patch source when the use-git-am option is enabled and hooks are not disabled during patch application. An attacker who can supply or influence such a source may achieve arbitrary code execution on the host with the privileges of the user running the build.
Affected context
The vulnerability can occur in build environments that use flatpak-builder to apply Git-formatted patch sources with use-git-am enabled. It requires a source under attacker influence to contain a Git hook and for the build process to apply that source without disabling or otherwise isolating hook execution.
Exploit preconditions
- Attack surface: The flatpak-builder source-processing and patch-application workflow
- Required access: Ability to provide, modify, or cause the build to consume a malicious patch source
- Trigger point: Application of the Git-formatted patch source during the build
- Why exploitation is possible: Git hooks are not disabled before the patch is applied, allowing hook code supplied through the source to execute in the build environment
Why this happens
The underlying bug is insufficient control over executable behavior in attacker-influenced Git content. When patch sources are applied with use-git-am enabled, Git hook execution remains available instead of being explicitly disabled or restricted. This maps to CWE-94, Code Injection, because data supplied as part of a source is interpreted as executable logic during a privileged build operation.
Potential impact
- Arbitrary code may execute on the host running flatpak-builder
- Build credentials, source code, or local configuration could be exposed
- Generated artifacts could be modified or poisoned
- The attacker could gain the privileges available to the build user
- Compromise could extend to other systems reachable from the build environment
General mitigation guidance
Mitigation generally focuses on preventing untrusted Git content from
triggering executable hooks during source preparation.
Common defensive patterns include:
- Disabling Git hooks by default whenever patch sources are applied
- Using restricted source-processing workflows that treat repository metadata as untrusted
- Separating source acquisition from build execution
- Running builds with dedicated, least-privileged identities and isolated workspaces
- Limiting filesystem, network, credential, and IPC access available to build processes
- Applying policy controls that reject sources containing executable repository hooks
- Keeping build inputs immutable and subject to provenance and integrity checks
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis and code review checks for patch-application paths that leave Git hooks enabled
- Tests using untrusted repositories or patch sources containing hook metadata
- Build-policy checks that prohibit executable hooks in fetched or generated inputs
- Runtime monitoring for unexpected child processes launched by flatpak-builder or its build helpers
- Audit records that correlate source acquisition, patch application, and process execution
- Automated security review tools that flag execution of repository-controlled behavior in build pipelines

