Chapter 29Lesson 03~175 minutes

Security Hardening, CSRF, Agent-to-Controller Controls, Script Security, CSP, TLS, and Reverse Proxies: Configuration, Design Choices, and Tradeoffs

Choose security controls deliberately: direct TLS or a reverse proxy, strict CSP or compatibility staging, sandboxed or trusted scripts, inbound TCP or WebSocket agents, and a minimal plugin set—always tied to the controller and agent state each choice changes.

Threat modelingTLS terminationCSP rolloutSandboxWebSocketPlugin surface

Learning objectives

  • Choose direct TLS or reverse-proxy TLS based on operational boundaries.
  • Roll out CSP without trading security for plugin UI breakage.
  • Choose sandboxed, approved or trusted script paths according to source trust.
  • Select inbound TCP or WebSocket agent connectivity without weakening Remoting controls.
  • Balance plugin capability against controller attack surface and rollback cost.

1. Security design choices are state choices

Hardening is not a list of universal toggles. Each decision moves responsibility between components. The correct design names who owns certificates, which process listens publicly, which scripts can execute outside the sandbox, which agents can reach privileged credentials and which plugins become part of the controller’s trusted computing base.

2. Direct TLS versus reverse-proxy TLS

Choice Advantages Risks / prerequisites Evidence
Jenkins terminates TLS Fewer moving parts; original request identity is direct Jenkins process owns certificate lifecycle; exposed port and renewal must be managed carefully Listener, certificate chain, Jenkins URL, cipher/protocol scan
Reverse proxy terminates TLS Central certificate/HTTP policy, common operational pattern, can isolate backend Forwarded headers, WebSocket upgrade, context path and backend exposure must be correct Proxy config revision, public/backend listener map, redirect/header tests

Neither choice authorizes users. Authentication and authorization still belong to Jenkins (or an explicitly designed upstream identity layer), and the backend should not become an accidental bypass path.

3. Strict CSP versus compatibility staging

Because general UI CSP can expose incompatible plugin UI behavior, a controlled rollout is preferable to “enable everywhere and hope.” Upgrade core/plugins, observe/report violations, test high-value screens, enable enforcement in a clone, then deploy with rollback notes. If a plugin cannot function without unsafe browser capabilities, treat that as plugin-governance debt rather than weakening policy for the entire controller.

User content needs separate treatment. Resource Root URL isolates user-generated files on another origin; this can be more robust than progressively weakening a same-origin CSP.

4. Sandboxed versus trusted scripts

Source Default posture Why
Repository Jenkinsfile / team-controlled DSL Sandboxed, least approvals Source authors are commonly less trusted than controller admins.
Reviewed Shared Library Sandboxed unless a narrow trusted library is operationally justified Trust converts library maintainers into controller-code maintainers.
Script Console Admin-only emergency/diagnostic use Unrestricted in-process code execution; no sandbox safety boundary.

Do not make “trusted” the default just to avoid approvals. Instead reduce the script’s required capability, use maintained Pipeline/plugin APIs, or isolate the admin operation behind a narrower interface.

5. Inbound TCP versus WebSocket agents

WebSocket allows an inbound agent to connect over the same HTTP(S) path as the Jenkins UI, simplifying firewall/proxy design. A dedicated inbound-agent TCP port may be appropriate in controlled networks but is another exposed service to govern. Neither transport removes the need for agent authentication, current Remoting, trust-class labels, or OS/filesystem isolation.

Current behavior. Agent→controller access control is always enabled on Jenkins 2.326+; there is no supported current tradeoff where you disable it to make an old plugin work.

6. Plugin convenience versus attack surface

Every controller plugin is privileged code and may expose HTTP endpoints, credentials types, build steps or deserialization paths. The smallest plugin set is easier to patch and test. A plugin that merely saves a few lines of shell or YAML may not justify a new controller dependency—especially if it is unmaintained or has unresolved security warnings.

Use the Chapter 25 governance model: exact version, dependencies, minimum core, security advisories, test path, rollback artifact and owner. Security hardening and plugin governance are the same control plane viewed from different angles.

7. Worked scenario: internal engineering controller

Assume 30 repositories, trusted release jobs and untrusted pull-request builds. The public entry point is a corporate HTTPS reverse proxy; agents are ephemeral.

Decision Choice Prerequisite Observable proof
TLS Proxy termination; Jenkins backend private Correct forwarded headers + WebSocket support Only proxy public; redirects remain HTTPS
Controller builds 0 built-in executors Agent pool exists Queued job never allocates controller
PR scripts Sandboxed + untrusted agent pool Script Security 1422+; no protected credentials Denied signatures/credentials remain denied
CSP Staged enforcement + Resource Root URL Plugin UI test inventory Violation report reviewed; headers present
Agent transport WebSocket Proxy forwards Upgrade/Connection Remoting connects through HTTPS entry point

8. Keep state domains distinct

  • Controller/JENKINS_HOME: security realm, authorization, executor count, plugin/script approvals, Jenkins URL.
  • Pipeline CPS: execution continuation—not agent OS isolation or TLS state.
  • Agent/workspace: process/filesystem identity; disposable build data.
  • Credentials: authorization to use a secret remains independent of transport security.
  • Archived evidence: headers/config snapshots prove configuration but do not prove an external target is healthy.
Next lesson

Diagnostics and failure modes

Use first-failure evidence to distinguish proxy/TLS, authentication/authorization, CSRF/session, script/plugin, agent/workspace and browser-content failures without removing the control that revealed them.

Knowledge check

Answer before revealing the explanation.

1. Why might a reverse proxy be preferable even though Jenkins can serve HTTP directly?

2. When a plugin breaks under CSP, what is the safer first response?

3. What changes when a Shared Library is configured as trusted?

4. Does choosing WebSocket agents remove agent trust concerns?

5. Why does plugin minimization belong in a security-hardening chapter?

Official references and version notes

Verified baseline — 17 September 2026. Labs target Jenkins 2.568.3 LTS with Java 21 (Jenkins 2.568.3 is tested with Java 21 and 25) and Script Security 1422.v06869826dd9b_. Script Security 1415.v9a_f9b_3a_c253d and earlier are affected by multiple sandbox vulnerabilities disclosed 16 September 2026. General Jenkins UI CSP is a core feature in Jenkins 2.539+ but is disabled by default because plugin compatibility varies; introduce it using report evidence and testing. Re-check Jenkins core/plugin advisories before applying these patterns to a long-lived controller.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.