Hermetic execution mode is currently an alpha experimental feature.
Overview
A Hermetic Build is a release engineering best practice that ensures builds are:- Self-contained - Don’t depend on anything outside the build environment
- Reproducible - Same inputs always produce same outputs
- Isolated - No network access during execution
- Reliable - Cannot fetch dependencies at runtime
- Downloading dependencies during build time
- Accessing external services
- Fetching remote resources
- Network-based attacks
Enabling Hermetic Execution
Prerequisites
- Set
enable-api-fieldsto"alpha"in thefeature-flagsConfigMap:
Enable for a TaskRun
- Add the hermetic execution annotation to your TaskRun:
Example: Hermetic TaskRun
This example demonstrates a TaskRun that should fail when hermetic mode is working correctly:Successful Hermetic TaskRun
Here’s an example that works correctly in hermetic mode by using only what’s in the container image:- The Go image contains the compiler
- Dependencies are vendored (included in the source)
- No network access is required
Use Cases
Secure CI/CD Pipelines
Ensure build steps cannot exfiltrate data or download malicious code:Reproducible Builds
Guarantee that builds produce identical outputs:Compliance and Auditing
Meet regulatory requirements for build isolation:Preparing for Hermetic Builds
To successfully run hermetic builds, prepare your environment:1. Vendor Dependencies
- Go
- Node.js
- Python
- Java/Maven
2. Use Appropriate Base Images
Choose images that contain all necessary tools:3. Pre-stage Artifacts
Mount workspaces with pre-downloaded dependencies:Troubleshooting
Network Access Errors
If you see errors like:Could not resolve hostConnection timeoutNetwork is unreachable
Debugging Hermetic Failures
Temporarily disable hermetic mode to identify network dependencies:Implementation Details
Hermetic execution mode is implemented by:- Configuring network policies for the TaskRun pod
- Disabling network interfaces in Step containers
- Blocking DNS resolution
- Preventing outbound connections
Limitations
Best Practices
- Test incrementally - Start with simple TaskRuns and gradually add complexity
- Vendor all dependencies - Don’t rely on network access during builds
- Use dependency locking - Pin exact versions (e.g.,
package-lock.json,Cargo.lock) - Pre-populate caches - Mount workspaces with pre-downloaded artifacts
- Verify offline mode - Test build commands with
--offlineflags locally - Document dependencies - Clearly list all required tools and libraries
- Separate fetch from build - Use separate Tasks for dependency download and compilation