Security Gates and Failure Policies
What you'll learn: How to configure thresholds that automatically stop deployments when security findings exceed acceptable risk levels.
What Are Security Gates?
Security gates are automated checkpoints in your CI/CD pipeline that evaluate security scan results and decide whether code can proceed to the next stage or must be blocked. Think of them as quality control inspectors on an assembly line—if a product doesn't meet standards, it doesn't ship.
These gates evaluate findings from SAST, dependency scanning, container scanning, DAST, and other security tools you've integrated into your pipeline. Without gates, your pipeline collects security data but takes no action on it.
Defining Failure Policies
A failure policy specifies when a gate should block a deployment. Common criteria include:
- Severity thresholds: Block if any critical vulnerabilities are found, or if high-severity findings exceed a count (e.g., >5)
- CVSS score limits: Fail builds with vulnerabilities scoring above 7.0
- Policy violations: Block on specific issues like hardcoded secrets or missing authentication
- Trend-based: Fail if new vulnerabilities are introduced compared to the previous build
Balancing Security and Velocity
Overly strict gates can block every deployment and frustrate developers. Too lenient gates allow vulnerabilities through. Effective policies often:
- Start permissive (warn-only mode) while establishing baselines
- Gradually tighten as teams adapt
- Allow documented exceptions for accepted risks
- Distinguish between environments: Stricter gates for production, more lenient for development
Example Decision Logic
IF critical_vulnerabilities > 0 THEN FAIL
IF high_vulnerabilities > 10 THEN FAIL
IF secrets_detected > 0 THEN FAIL
ELSE PASS
Key Takeaway: Security gates with well-defined failure policies transform security scanning from informational to enforceable, automatically preventing risky code from reaching production while maintaining development velocity through thoughtful threshold configuration.