Jenkins Hardening Guide
CI/CD security hardening for Jenkins including authorization, agent security, and pipeline protection
Overview
Jenkins is the most widely used open-source CI/CD automation server, powering build pipelines for millions of projects across enterprises worldwide. As a critical component deeply integrated into software delivery processes, Jenkins has access to source code, deployment credentials, and production systems. A single misconfiguration can compromise the entire build environment and supply chain.
Intended Audience
- Security engineers managing CI/CD infrastructure
- DevOps administrators configuring Jenkins
- GRC professionals assessing build security
- Platform engineers implementing secure pipelines
How to Use This Guide
- L1 (Baseline): Essential controls for all organizations
- L2 (Hardened): Enhanced controls for security-sensitive environments
- L3 (Maximum Security): Strictest controls for regulated industries
Scope
This guide covers Jenkins security configurations including authentication, authorization, agent security, and pipeline hardening for both Jenkins Controller and Jenkins Cloud deployments.
Table of Contents
- Authentication & Access Control
- Authorization & Permissions
- Controller & Agent Security
- Pipeline Security
- Monitoring & Compliance
- Compliance Quick Reference
1. Authentication & Access Control
1.1 Enable Authentication
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 6.3 |
| NIST 800-53 | IA-2 |
Description
Enable authentication to prevent anonymous access to Jenkins. By default, older Jenkins installations may allow anonymous access.
Rationale
Why This Matters:
- Anonymous access allows anyone to view jobs, credentials, and configurations
- Attackers can trigger builds or modify pipelines without authentication
- Authentication is the foundation for authorization controls
ClickOps Implementation
Step 1: Enable Security
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Check Enable security (if not already enabled)
- Configure security realm (authentication method)
Step 2: Configure Security Realm
- Select appropriate security realm:
- Jenkins’ own user database: For small deployments
- LDAP: For enterprise directory integration
- SAML 2.0: For SSO with identity providers (recommended)
- Configure realm settings
Step 3: Disable Anonymous Access
- Under Authorization, ensure anonymous users have no permissions
- Do not select “Anyone can do anything”
- Do not select “Logged-in users can do anything” (see 2.1)
Time to Complete: ~30 minutes
Code Implementation
1.2 Configure LDAP or SAML SSO
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 6.3, 12.5 |
| NIST 800-53 | IA-2, IA-8 |
Description
Configure centralized authentication using LDAP or SAML SSO for enterprise identity management.
Prerequisites
- LDAP directory or SAML IdP available
- LDAP Plugin or SAML Plugin installed
ClickOps Implementation (SAML)
Step 1: Install SAML Plugin
- Navigate to: Manage Jenkins → Plugins → Available plugins
- Search for “SAML”
- Install SAML Single Sign On(SSO) plugin
- Restart Jenkins
Step 2: Configure SAML
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Select SAML 2.0 as Security Realm
- Configure:
- IdP Metadata URL or XML
- Username attribute
- Email attribute
- Group attribute (for role mapping)
- Configure SP settings and download metadata
Step 3: Configure IdP
- Create application in IdP
- Upload Jenkins SP metadata
- Configure attribute mappings
- Assign users/groups
**ClickOps Implementation (LDAP)
Step 1: Configure LDAP
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Select LDAP as Security Realm
- Configure:
- Server:
ldaps://ldap.example.com:636 - Root DN:
dc=example,dc=com - User search base:
ou=users - User search filter:
uid={0} - Group search base:
ou=groups
- Server:
- Test LDAP connection
Code Implementation
1.3 Disable Remember Me
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 6.2 |
| NIST 800-53 | AC-12 |
Description
Disable the “Remember me” feature to prevent persistent authentication tokens.
ClickOps Implementation
Step 1: Disable Remember Me
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Uncheck Allow users to sign up (if using Jenkins user database)
- Configure session timeout
Step 2: Configure Session Settings
- Edit
jenkins.xmlor use System Properties (see Groovy init script in SDK Code Pack below)
2. Authorization & Permissions
2.1 Configure Matrix-Based Security
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 5.4 |
| NIST 800-53 | AC-6 |
Description
Configure Matrix-based security for fine-grained permission control. This is recommended over “Logged-in users can do anything.”
Rationale
Why This Matters:
- “Logged-in users can do anything” gives all authenticated users admin access
- Combined with open signup, anyone can become an admin
- Matrix security enables granular permission control
ClickOps Implementation
Step 1: Enable Matrix Authorization
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Under Authorization, select Matrix-based security
Step 2: Configure Permissions
- Add users and groups to the matrix
- Assign minimum necessary permissions:
| Permission | Admins | Developers | Viewers |
|---|---|---|---|
| Overall/Administer | ✅ | ❌ | ❌ |
| Overall/Read | ✅ | ✅ | ✅ |
| Job/Build | ✅ | ✅ | ❌ |
| Job/Configure | ✅ | ❌ | ❌ |
| Job/Read | ✅ | ✅ | ✅ |
| Credentials/View | ✅ | ❌ | ❌ |
Step 3: Remove Default Authenticated Group
- Remove or restrict the
authenticatedgroup permissions - Grant permissions to specific groups/users only
Code Implementation
2.2 Configure Project-Based Matrix Authorization
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 5.4 |
| NIST 800-53 | AC-6(1) |
Description
Enable project-based authorization for per-project access control.
Prerequisites
- Matrix Authorization Strategy Plugin installed
ClickOps Implementation
Step 1: Enable Project-Based Matrix
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Select Project-based Matrix Authorization Strategy
Step 2: Configure Global Permissions
- Set minimal global permissions
- Most permissions will be set at project level
Step 3: Configure Project Permissions
- Navigate to: Job → Configure → Enable project-based security
- Add users/groups with project-specific permissions
- Example: “Joe can access projects A, B, and C, but not D”
Code Implementation
2.3 Configure Role-Based Access Control
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 5.4 |
| NIST 800-53 | AC-6(1) |
Description
Implement role-based access control for scalable permission management.
Prerequisites
- Role-based Authorization Strategy Plugin installed
ClickOps Implementation
Step 1: Enable Role-Based Strategy
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Select Role-Based Strategy
Step 2: Define Roles
- Navigate to: Manage Jenkins → Manage and Assign Roles → Manage Roles
- Create global roles:
admin: Full permissionsdeveloper: Build and read permissionsviewer: Read-only permissions
Step 3: Create Project Roles
- Create item roles with patterns:
- Role:
team-a-dev, Pattern:team-a-.* - Role:
team-b-dev, Pattern:team-b-.*
- Role:
- Assign item-specific permissions
Step 4: Assign Roles
- Navigate to: Manage and Assign Roles → Assign Roles
- Assign global roles to users/groups
- Assign item roles to users/groups
Code Implementation
2.4 Restrict Script Console Access
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 5.4 |
| NIST 800-53 | AC-6(1) |
Description
Restrict access to the Script Console to administrators only.
Rationale
Why This Matters:
- Script Console provides Groovy script execution
- Can access all Jenkins internals, credentials, and system
- Unlimited code execution capability
ClickOps Implementation
Step 1: Verify Script Console Permissions
- Navigate to: Manage Jenkins → Security → Configure Global Security
- In authorization matrix, ensure only admins have
Overall/Administer - Script Console requires
Overall/Administerpermission
Step 2: Audit Script Console Access
- Review who has admin access
- Consider separate admin accounts for privileged operations
- Log and alert on Script Console usage
Code Implementation
3. Controller & Agent Security
3.1 Enable Agent to Controller Access Control
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 13.5 |
| NIST 800-53 | AC-4 |
Description
Enable Agent → Controller Access Control to prevent compromised agents from attacking the controller.
Rationale
Why This Matters:
- Agent processes could be taken over by malicious users
- Without controls, agents can send commands to controller
- This prevents agents from accessing sensitive controller data
ClickOps Implementation
Step 1: Enable Access Control
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Under Agent → Controller Security, enable access control
- Configure allowed/denied commands
Step 2: Review Allowed Commands
- Navigate to: Manage Jenkins → Security → Agent → Controller Security
- Review whitelisted file path rules
- Review whitelisted commands
- Remove unnecessary allowances
Code Implementation
3.2 Disable Builds on Controller
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 4.1 |
| NIST 800-53 | CM-7 |
Description
Configure Jenkins to run builds only on agents, not on the controller node.
Rationale
Why This Matters:
- Controller has access to all configurations, credentials, and secrets
- Builds running on controller can access sensitive data
- Compromised builds can attack Jenkins internals
ClickOps Implementation
Step 1: Configure Controller Executors
- Navigate to: Manage Jenkins → Nodes → Built-In Node → Configure
- Set Number of executors to 0
- Save configuration
Step 2: Configure Labels
- Ensure jobs are configured to run on specific agent labels
- Never use “any” or empty label restrictions
Code Implementation
3.3 Use Ephemeral Agents
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 4.1 |
| NIST 800-53 | CM-6 |
Description
Use ephemeral (disposable) agents that are created fresh for each build.
ClickOps Implementation
Step 1: Configure Cloud Agents
- Navigate to: Manage Jenkins → Clouds
- Configure cloud provider:
- Kubernetes
- Amazon EC2
- Docker
- Configure agent templates
Step 2: Kubernetes Pod Template Example
- Install Kubernetes Plugin
- Configure pod template (see CLI Code Pack below for K8s pod spec)
Step 3: Configure Auto-Scaling
- Set minimum instances to 0
- Configure scale-up triggers
- Set idle timeout for termination
Code Implementation
3.4 Secure Agent Communication
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 3.10 |
| NIST 800-53 | SC-8 |
Description
Secure communication between agents and controller using JNLP over TLS.
ClickOps Implementation
Step 1: Configure Agent Protocols
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Under Agent protocols, disable insecure protocols
- Enable only Inbound TCP Agent Protocol/4 (TLS encryption)
Step 2: Configure HTTPS
- Configure Jenkins to run behind HTTPS reverse proxy
- Or configure HTTPS directly in Jenkins (see CLI Code Pack below)
Code Implementation
4. Pipeline Security
4.1 Enable CSRF Protection
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 16.13 |
| NIST 800-53 | SC-8 |
Description
Enable CSRF protection to prevent cross-site request forgery attacks.
ClickOps Implementation
Step 1: Enable CSRF Protection
- Navigate to: Manage Jenkins → Security → Configure Global Security
- Under CSRF Protection, select Default Crumb Issuer
- Optionally enable Enable proxy compatibility if behind a reverse proxy
Code Implementation
4.2 Secure Credentials Management
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 3.11 |
| NIST 800-53 | SC-12 |
Description
Securely manage credentials using Jenkins Credentials Plugin with appropriate scoping.
ClickOps Implementation
Step 1: Organize Credentials by Scope
- Navigate to: Manage Jenkins → Credentials
- Create credential domains for different purposes:
production-deploymentstesting-resourcesthird-party-integrations
Step 2: Use Folder-Scoped Credentials
- Create folders for different teams/projects
- Store credentials at folder level (not global)
- Only jobs in folder can access credentials
Step 3: Configure Credential Types
- Prefer:
- SSH Username with private key
- Secret file
- Certificates
- Avoid:
- Username with password (when possible)
Step 4: Audit Credential Usage
- Install Credentials Binding Plugin
- Use
withCredentialsin pipelines for explicit binding - Audit which jobs use which credentials
Code Implementation
4.3 Implement Pipeline Sandbox
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 16.1 |
| NIST 800-53 | CM-7 |
Description
Use Pipeline Groovy Sandbox to restrict what pipeline scripts can do.
Rationale
Why This Matters:
- Unrestricted pipelines can execute arbitrary Groovy code
- Can access Jenkins internals, file system, network
- Sandbox restricts to approved methods only
ClickOps Implementation
Step 1: Configure Script Security
- Navigate to: Manage Jenkins → In-process Script Approval
- Review and approve only necessary script signatures
- Do not approve requests without review
Step 2: Use Declarative Pipelines
- Prefer declarative pipelines over scripted (see SDK Code Pack below for example)
Step 3: Restrict Script Approval
- Limit who can approve scripts
- Review all approval requests carefully
- Consider security implications of each approval
Code Implementation
4.4 Secure Jenkinsfile Configuration
Profile Level: L2 (Hardened)
| Framework | Control |
|---|---|
| CIS Controls | 16.9 |
| NIST 800-53 | CM-3 |
Description
Implement secure Jenkinsfile practices to prevent pipeline attacks.
Code Implementation
See the SDK Code Pack below for a secure Jenkinsfile template demonstrating hardened pipeline practices.
5. Monitoring & Compliance
5.1 Enable Audit Logging
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 8.2 |
| NIST 800-53 | AU-2 |
Description
Enable comprehensive audit logging for security monitoring.
Prerequisites
- Audit Trail Plugin installed
ClickOps Implementation
Step 1: Install Audit Trail Plugin
- Navigate to: Manage Jenkins → Plugins → Available plugins
- Install Audit Trail plugin
- Restart Jenkins
Step 2: Configure Audit Trail
- Navigate to: Manage Jenkins → System → Audit Trail
- Add logger:
- Log file:
/var/log/jenkins/audit.log - Or Syslog server for SIEM integration
- Log file:
- Configure log pattern and events
Key Events to Monitor:
- Login/logout events
- Configuration changes
- Job creation/deletion
- Credential access
- Build triggers
Code Implementation
5.2 Keep Jenkins Updated
Profile Level: L1 (Baseline)
| Framework | Control |
|---|---|
| CIS Controls | 7.3 |
| NIST 800-53 | SI-2 |
Description
Keep Jenkins and all plugins updated with security patches.
ClickOps Implementation
Step 1: Check for Updates
- Navigate to: Manage Jenkins → Manage Plugins → Updates
- Review available updates
- Prioritize security updates
Step 2: Configure Update Center
- Navigate to: Manage Jenkins → Manage Plugins → Advanced
- Verify update site URL
- Consider using LTS release line for stability
Best Practices:
- Follow biweekly update cadence
- Stay on latest supported hot-patch release
- Test updates in non-production first
- Subscribe to Jenkins security advisories
Code Implementation
6. Compliance Quick Reference
SOC 2 Trust Services Criteria Mapping
| Control ID | Jenkins Control | Guide Section |
|---|---|---|
| CC6.1 | Authentication | 1.1 |
| CC6.1 | SSO | 1.2 |
| CC6.2 | Authorization | 2.1 |
| CC6.6 | Agent security | 3.1 |
| CC7.2 | Audit logging | 5.1 |
NIST 800-53 Rev 5 Mapping
| Control | Jenkins Control | Guide Section |
|---|---|---|
| IA-2 | Authentication | 1.1 |
| AC-6 | Least privilege | 2.1 |
| AC-6(1) | RBAC | 2.3 |
| CM-7 | Minimize function | 3.2 |
| AU-2 | Audit logging | 5.1 |
Appendix A: Essential Security Plugins
| Plugin | Purpose | Priority |
|---|---|---|
| SAML Plugin | SSO authentication | High |
| Role-based Authorization Strategy | Fine-grained RBAC | High |
| Audit Trail | Security logging | High |
| Credentials Binding | Secure credential usage | High |
| Folders | Credential scoping | Medium |
| Configuration as Code | Automated security config | Medium |
Appendix B: References
Official Jenkins Documentation:
- Jenkins Documentation
- Managing Security
- Securing Jenkins
- Jenkins Security Advisories
- Jenkins Security Page
API & Developer Resources:
Plugins:
Compliance Frameworks:
- Jenkins is an open-source project and does not hold SOC 2, ISO 27001, or similar certifications as a product. Organizations self-hosting Jenkins are responsible for their own compliance posture. CloudBees, the commercial Jenkins vendor, maintains its own compliance certifications for CloudBees CI.
Security Incidents:
- CVE-2024-23897 (CVSS 9.8): Critical path traversal flaw in Jenkins CLI allowing unauthenticated arbitrary file read; actively exploited in ransomware attacks and added to CISA KEV catalog. Fixed in Jenkins 2.442 and LTS 2.426.3.
- Jenkins regularly publishes security advisories at jenkins.io/security/advisories covering core and plugin vulnerabilities.
Third-Party Resources:
Changelog
| Date | Version | Maturity | Changes | Author |
|---|---|---|---|---|
| 2026-02-19 | 0.1.1 | draft | Migrate inline code to SDK/CLI Code Packs (1.3, 3.3, 3.4, 4.3, 4.4); remove lang= from includes | Claude Code (Opus 4.6) |
| 2025-02-05 | 0.1.0 | draft | Initial guide with authentication, authorization, and pipeline security | Claude Code (Opus 4.5) |
Contributing
Found an issue or want to improve this guide?
- Report outdated information: Open an issue with tag
content-outdated - Propose new controls: Open an issue with tag
new-control - Submit improvements: See Contributing Guide