T03 · Remote Payload Retrieval and Execution
- Location
cicd_gen/generator/gitlab_ci.py:94- Finding
Unverified Codecov Script Downloaded and Executed in GitLab CI
- Content
View full analysis
Vulnerability Details
File Location:
cicd_gen/generator/gitlab_ci.py:94-101
Vulnerability Type: Remote payload retrieval and execution
Risk Level: CriticalVulnerable Code:
python if coverage: pipeline["coverage"] = { "image": image, "stage": "coverage", "script": ["curl -s https://codecov.io/bash | bash"], "needs": ["test"], }Technical Analysis
When coverage is enabled, the generator creates a GitLab CI job that retrieves a script from
https://codecov.io/bashand pipes the response directly into Bash. The remote content is not pinned to an immutable version and is not validated using a checksum or cryptographic signature.This design makes the effective code executed by the pipeline dependent on whatever content the remote endpoint returns at runtime. Compromise of the endpoint, its hosting infrastructure, or the associated network trust path could therefore turn the coverage job into an arbitrary-code execution channel.
Coverage processing and upload do not inherently require executing a mutable remote response. The behavior exceeds the minimum privileges necessary for the declared coverage-reporting functionality.
Attack Path
- A user enables coverage and generates a GitLab CI configuration.
- The generated
.gitlab-ci.ymlis committed and executed by a GitLab runner. - The coverage job requests the current content of
https://codecov.io/bash. - An upstream compromise or malicious response supplies attacker-controlled shell commands.
- Bash executes those commands under the GitLab runner account.
- The payload can access resources exposed to the job, including the checkout, artifacts, network connectivity, and any CI variables available to that job.
Impact Assessment
Successful exploitation provides arbitrary command execution with the privileges of the GitLab runner job. Depending on runner configuration and variable p ...[truncated 386 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
curl | bashexecution pattern. - Prefer GitLab's native Cobertura artifact support when external upload is unnecessary.
- If Codecov upload is required, use an official, fixed-version uploader rather than the mutable legacy Bash endpoint.
- Download the uploader as a separate step, verify a vendor-published cryptographic checksum or signature, and only then execute it.
- Pin any uploader container to an immutable image digest.
- Restrict the coverage job's CI variables and runner permissions to the minimum required.
- Add automated tests that reject generated pipeline commands matching network-to-shell patterns such as
curl ... | bashorwget ... | sh.
- Remove the
