Mitigation Strategy: Pipeline Definition Security (Declarative Pipelines)
- Version Control: Store all Jenkinsfile definitions, which define declarative pipelines using the
pipeline-model-definition-plugin
, in a version control system like Git. - Code Review Process: Implement a mandatory code review process specifically for Jenkinsfile defining declarative pipelines. This includes reviewing the declarative structure, steps used, and any embedded
script
blocks. - Branching Strategy: Adopt a branching strategy to manage different versions of declarative pipelines (development, staging, production) defined by Jenkinsfile.
- Unauthorized Pipeline Modification (High Severity): Malicious actors could modify declarative pipeline definitions to inject malicious steps or alter the intended workflow.
- Accidental Pipeline Breakage (Medium Severity): Errors in declarative pipeline syntax or step configuration can lead to broken builds.
- Lack of Auditability (Medium Severity): Without version control for Jenkinsfile, tracking changes to declarative pipelines becomes difficult.
- Unauthorized Pipeline Modification (High Impact): Significantly reduces risk by controlling changes to declarative pipeline definitions.
- Accidental Pipeline Breakage (Medium Impact): Reduces risk by introducing review and versioning for declarative pipelines.
- Lack of Auditability (Medium Impact): Provides audit trail for declarative pipeline changes.
Version control (Git) for Jenkinsfile. Code review partially implemented. Branching strategy in place.
Formalized code review for Jenkinsfile defining declarative pipelines. Consistent enforcement of code review for all declarative pipeline changes.
Mitigation Strategy: Scripted Pipeline Blocks within Declarative Pipelines
- Favor Declarative Syntax: Prioritize using the declarative syntax and built-in steps provided by the
pipeline-model-definition-plugin
and other Jenkins plugins. - Avoid
script
Blocks: Actively avoid usingscript
blocks within declarative pipelines unless absolutely necessary and no declarative alternative exists. - Educate Developers: Train developers on the security implications of
script
blocks in declarative pipelines and promote declarative best practices.
- Script Injection Vulnerabilities (High Severity):
script
blocks introduce Groovy scripting into declarative pipelines, increasing the risk of injection attacks. - Unintended Code Execution (Medium Severity): Uncontrolled Groovy code in
script
blocks can lead to unexpected behavior and security issues within declarative pipelines. - Complexity and Maintainability (Medium Severity): Excessive use of
script
blocks makes declarative pipelines harder to understand and maintain.
- Script Injection Vulnerabilities (High Impact): Significantly reduces risk by limiting the use of
script
blocks in declarative pipelines. - Unintended Code Execution (Medium Impact): Reduces risk by promoting structured declarative pipeline definitions.
- Complexity and Maintainability (Medium Impact): Improves maintainability of declarative pipelines.
Developers generally encouraged to use declarative syntax. No formal policies in place.
Formal training on declarative pipeline best practices and script
block security. Clear guidelines on script
block usage in declarative pipelines.
Mitigation Strategy: Strictly Review and Sanitize script
Blocks (within Declarative Pipelines)
- Mandatory Code Review for
script
: Require rigorous code review specifically for anyscript
blocks used within declarative pipelines. - Security Checklist for
script
: Develop a checklist for reviewers focusing on security aspects ofscript
blocks in declarative pipelines, including input validation, command injection prevention, and least privilege. - Sanitization Functions for
script
: Provide developers with reusable functions for sanitizing inputs withinscript
blocks in declarative pipelines.
- Script Injection Vulnerabilities (High Severity): Addresses injection risks within
script
blocks in declarative pipelines through review and sanitization. - Command Injection Vulnerabilities (High Severity): Specifically mitigates command injection risks within shell commands executed from
script
blocks in declarative pipelines. - Information Disclosure (Medium Severity): Helps prevent information leaks from
script
blocks in declarative pipelines.
- Script Injection Vulnerabilities (High Impact): Significantly reduces risk through security-focused review of
script
blocks in declarative pipelines. - Command Injection Vulnerabilities (High Impact): Directly mitigates command injection in
script
blocks within declarative pipelines. - Information Disclosure (Medium Impact): Reduces risk of leaks from
script
blocks in declarative pipelines.
Code reviews are performed, but security-specific review for script
blocks in declarative pipelines is not formalized.
Security-focused review checklist for script
blocks in declarative pipelines. Reusable sanitization functions for script
blocks. Formal training for reviewers.
Mitigation Strategy: Parameter Validation and Sanitization (Declarative Pipelines)
- Declarative Parameter Types: Utilize specific parameter types offered by the
pipeline-model-definition-plugin
in declarative pipelines (e.g.,string
,choice
,boolean
). - Validation Rules for Declarative Parameters: Use validation rules (e.g., regular expressions for
string
parameters) within declarative pipeline parameter definitions to restrict input. - Sanitization in Declarative Pipelines: Implement or use sanitization functions within declarative pipeline scripts (especially in
script
blocks if used) to sanitize parameter values before use.
- Command Injection Vulnerabilities (High Severity): Prevents command injection via parameters used in declarative pipelines.
- Script Injection Vulnerabilities (High Severity): Reduces script injection risks from parameters in declarative pipelines.
- Cross-Site Scripting (XSS) (Medium Severity): Sanitization can help prevent XSS if declarative pipeline output with parameters is displayed in web context.
- Command Injection Vulnerabilities (High Impact): Significantly reduces risk of parameter-based command injection in declarative pipelines.
- Script Injection Vulnerabilities (High Impact): Reduces risk of script injection via parameters in declarative pipelines.
- Cross-Site Scripting (XSS) (Medium Impact): Provides defense against XSS in specific declarative pipeline contexts.
Parameter types are used. Basic validation might be implicit. No dedicated sanitization for declarative pipeline parameters.
Systematic parameter validation rules in declarative pipelines. Sanitization functions for declarative pipeline parameters. Developer training on secure parameter handling in declarative pipelines.