Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4564] Restructure Security section #4612

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9703d7b
[4564] Add conceptual info to security introduction
Oct 5, 2021
6c727c3
move note about "Enable Security" checkbox back to "Managing Security"
Oct 5, 2021
8163c74
delete bogus link to a PR
Oct 5, 2021
a604ac6
Merge branch 'master' into 1004-security-overview
Oct 6, 2021
708997b
Moved info about who affects Pipeline from controller-isolation.adoc
Oct 7, 2021
e68d0ad
Merge branch '1004-security-overview' of github.com:StackScribe/jenki…
Oct 7, 2021
dcad943
Merge branch 'master' into 1004-security-overview
Oct 7, 2021
d568df4
Merge branch 'master' into 1004-security-overview
Oct 8, 2021
721f907
minor edits
Oct 13, 2021
0ffb510
Pipelines -> jobs
Oct 14, 2021
7fb49ce
Add concepts-security page
Oct 19, 2021
bdf825b
moving files in _chapter.yml
Oct 20, 2021
033a397
Add rewritten controller-isolation from PR4635
Oct 20, 2021
db5a03e
Move TCP port info into its own page
Oct 20, 2021
6639fec
Removed a bit of crud
Oct 20, 2021
5e0b503
Rename securing-jenkins to be a placeholder for those wiki links
Oct 20, 2021
5f4e5d4
Remove "Agents and Security" info from index.ado
Oct 20, 2021
557c68d
Move Access Control info from managing-security to access-control
Oct 20, 2021
0eeeb0b
Add "story" (outline of chapter) to index.adoc
Oct 20, 2021
70098e6
Consolidate access control info in one page
Oct 23, 2021
da01b25
fix link to security advisories
Oct 26, 2021
6f81a40
fix link to security advisories
Oct 26, 2021
b8d7c1e
fix link to managing-security
Oct 26, 2021
28e443a
remove solopsistic link
Oct 26, 2021
e7f5165
delete extraneous title
Oct 26, 2021
f7d4100
an user -> an user
Oct 26, 2021
b1519f3
Draft "Configure Global Security" page
Oct 26, 2021
6109f6a
Refine definitions of nodes and executors
Oct 26, 2021
52b9f64
remove details about nodes
Dec 9, 2021
b750b91
remove details about agents/exectors on controller
Dec 9, 2021
228fb0f
remove some details about number of executors
Dec 9, 2021
1a08475
one sentence per line
Jan 10, 2022
c6eff48
one sentence per line
Jan 10, 2022
23c078f
one sentence per line
Jan 10, 2022
27429db
one sentence per line
Jan 10, 2022
9f431b8
one sentence per line
Jan 10, 2022
184cd91
one sentence per line
Jan 10, 2022
cd21cad
one sentence per line
Jan 10, 2022
35b4ed8
Update content/doc/book/security/index.adoc
Jan 10, 2022
87c2ab8
one sentence per line
Jan 10, 2022
808d2aa
one sentence per line
Jan 10, 2022
b061d8d
one sentence per line
Jan 10, 2022
7f61450
one sentence per line
Jan 10, 2022
0bc82cd
Pare down description of distributed components
Jan 11, 2022
f6096fd
Clarify that only 0 executors on controller guarantees no builds
Jan 11, 2022
384fe9d
Merge branch 'master' into 1004-security-overview
MarkEWaite Jan 13, 2022
ca895cd
Resolving some dbeck comments
Jan 20, 2022
ba6730b
Remove admonition to not configure TCP port if you don't need it
Jan 21, 2022
9849ee6
rephrase material about jobs being able to do anything
Jan 21, 2022
27afddd
one sentence per line -- part 1
Jan 21, 2022
9ad1afa
Merge branch '1004-security-overview' of github.com:StackScribe/jenki…
Jan 21, 2022
c545ed7
restore TODO about Agent -> Controller version
Jan 21, 2022
dd7768a
details about agent->controller in that page; disabling is history
Jan 21, 2022
bc3212c
Advice to revisit security configuration moved from index to concepts
Jan 21, 2022
aec1a09
one sentence per line
Jan 21, 2022
2c46b5a
delete securing-jenkins.adoc -- dbeck says these wiki links are obsolete
Jan 21, 2022
d512ff7
InBound -> Inbound
Jan 21, 2022
1609c80
Merge branch '1004-security-overview' of github.com:StackScribe/jenki…
Jan 21, 2022
2549d42
fix indentation
Jan 21, 2022
fb96a9e
Merge branch '1004-security-overview' of github.com:StackScribe/jenki…
Jan 21, 2022
8b9af00
"Jenkins Access Control" -> "Access Control"
Jan 21, 2022
ed0e597
How Jenkins executes Pipeline -> job
Jan 23, 2022
89adbc6
Deleted securing-jenkins from _chapter.yml
Jan 23, 2022
d5b6325
new file for "How Jenkins Executes a Job"; rename "Security Concepts"
Jan 26, 2022
1d349e8
Remove links to pages for fields on Configure Security page from inde…
Jan 26, 2022
4b4ced3
Move Agent -> Controller Security into controller-isolation.adoc
Jan 26, 2022
e92c6f7
fix xref
Jan 26, 2022
b886850
Merge branch 'master' into 1004-security-overview
MarkEWaite Aug 5, 2022
be0f0aa
Merge branch 'master' into 1004-security-overview
MarkEWaite Aug 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 105 additions & 7 deletions content/doc/book/security/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,113 @@ ifdef::backend-html5[]
:sectanchors:
endif::[]

Jenkins is used everywhere from workstations on corporate intranets, to high-powered servers connected to the public internet.
To safely support this wide spread of security and threat profiles, Jenkins offers many configuration options for enabling, customizing, or disabling various security features.

Many of the security options are enabled by default when passing the interactive setup wizard to ensure that Jenkins is secure.
Others involve environment-specific setup and trade-offs and depend on specific use cases supported in individual Jenkins instances.

This chapter will introduce the various security options available to Jenkins administrators and users, explaining the protections offered, and trade-offs to disabling some of them.
Jenkins is used everywhere -- from workstations on corporate intranets
to high-powered servers connected to the public internet.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
It is critically important to keep your Jenkins instance secure,
both to protect your information and to avoid executing malicious code from your Jenkins instance.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

Your Jenkins environment is a fully-distributed build system.
Each network connection is a potential point of entry.
Remember that the code that runs your builds can be perverted to run anything!

Jenkins and the Pipelines it runs must be able to do almost anything.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
This means that a malicious Pipeline could reconfigure the Jenkins instance,
delete files, or launch various forms of mischief
such as a DDoS attack pr a bot.
In addition to deliberate and direct attacks on your environment,
a trusted user could visit an infected web site
and accidentally introduce malicious code into the Jenkins instance.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

Jenkins includes configurable features to secure your Jenkins instance
against the various security and threat profiles.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
The setup wizard enables many of the security options by default,
to ensure that Jenkins is secure.
Other security options involve environment-specific setup and trade-offs
and depend on specific use cases supported for individual Jenkins instances.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
Configuration options allow you to enable, customize, or disable security features.

This chapter introduces the various security options available to Jenkins administrators and users,
explaining the protections offered, and trade-offs to disabling some of them.

== Security Principles

Security principles should guide the practices and tools used to fight and prevent threats.
The major principles for security are:

* *Least privilege:*
Give people the privileges required to do their jobs
but do not give everyone permission to do everything
and do not open ports that are not required for your work.

* *Know the system:*
The more you understand about how your system works,
the more you are prepared to protect the integrity of your system.

* *Defense in depth:*
Systems are layered.
Put security on all layers.

* *Prevention is good, but detection is better:*
Monitor your Jenkins installation constantly
so that you quickly detect signs of a security breach.

* *Keep your system current:*
Pay attention to
link:https://www.jenkins.io/security/advisories/[Security Advisories]
and apply
link:https://www.jenkins.io/security/for-administrators/#how-quickly-should-i-apply-security-updates[Security Updates]
as soon as possible!
Keeping the Jenkins software and all plugins current
also helps ensure that your system is secure.

== How Jenkins Executes a Pipeline

A simple overview of how Jenkins executes a Pipeline
helps to understand the security considerations.

By default, a Pipeline executes with the full privileges of the Jenkins administrator,
although you can configure Jenkins to execute Pipelines with fewer privileges.
All of the Pipeline logic, the Groovy conditionals, loops, and so forth execute on the controller.

When a Pipeline runs:

* For each build that runs, Jenkins creates a _workspace_ on the controller
where files for that build are stored.
* The Pipeline calls a series of _steps_,
each of which is a script or command that does the real work
and mostly executes using an _executor_ on an _agent_.

The agent:

* Writes some files to the local node.
* Sends data back to the controller.
* May also request information from the controller.

== Agents and Security

Never run builds on the Jenkins controller in production environments.
A build job that uses an agent running on the built-in controller node
has access to Jenkins controller files and configuration, which poses a security risk.
Configuring Jenkins as a distributed system,
where builds execute on agents that are separate from the controller
instead of the built-in node on the controller,
enhances the security of your Jenkins instance
as well as improving its performance and making it more stable.

An agent that executes on the Jenkins controller
may be able to access Jenkins configuration files and the workspaces of other builds.
An agent could also request information
that belongs to other teams or organizations that share the controller.

An agent can also write malicious code to its local disk so that the node is tainted.
For maximum security, run all builds on ephemeral agents in the cloud
that are destroyed at the end of each build job.

NOTE: A job that performs administrative tasks such as backups may run on the controller,
but be sure to label the executor and only allow it to be used by jobs that specify that label.
Copy link
Contributor

@daniel-beck daniel-beck Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a potential problem, as pipeline authors can configure their pipelines to run on node('master || built-in') and suddenly other stuff is running. https://plugins.jenkins.io/job-restrictions/ exists, but out of the box, only zero executors can prevent that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole sub-section is being merged with the info in the controller-isolation.adoc file. See #4635 . I will modify the note in that PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See lines 45ff in the controller-isolation.adoc file. I did not include the syntax that Pipeline authors can use to access a labeled executor. I figured we didn't want to make this a how-to manual, right?


// TODO the following only makes sense on the web site, not the PDF. Can it be disabled there?
// TODO the material below should be moved to other sections in this chapter.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

== Basic Setup

Expand Down
33 changes: 20 additions & 13 deletions content/doc/book/security/managing-security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ Pages to mark as deprecated by this document:
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/jenkins/security/s2m/MasterKillSwitchConfiguration/help-masterToagentAccessControl.html#L2
/content/redirect/security-144

[NOTE]
.Enable Security
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
====
Versions before Jenkins 2.214 and Jenkins LTS 2.222.1
included an *Enable Security* checkbox on the *Configure Global Security* page.
This checkbox was selected by default
with the recommendation that it never be unchecked,
especially on production systems.
This enforced that only users who were authenticated
(in other words, logged in with with a username and password,
enforced either by Jenkins or by alernate Security Realm)
could access Jenkins.
The Jenkins user database was defined as the default security realm in these same releases.

The "Enable Security" checkbox has been removed from current releases
(beginning with Jenkins 2.214 and Jenkins LTS 2.222.1)
because it should never be disabled.
====

////

Jenkins is used everywhere from workstations on corporate intranets, to
Expand All @@ -36,19 +55,7 @@ This section will introduce the various security options available to a Jenkins
administrator, explaining the protections offered, and trade-offs to disabling
some of them.


== Enabling Security

Beginning with Jenkins 2.214 and Jenkins LTS 2.222.1, the "Enable Security" checkbox has been removed.
Jenkins own user database is used as the default security realm.

In versions before Jenkins 2.214 and Jenkins LTS 2.222.1, when the *Enable Security* checkbox is checked,
users can log in with a username and password in order to
perform operations not available to anonymous users. Which operations require
users to log in depends on the chosen authorization strategy and its configuration;
by default anonymous users have no permissions, and logged in users have full
control. The "Enable Security" checkbox should *always* be enabled for any non-local (test) Jenkins
environment.
== Configure Global Security page

The "Configure Global Security" section of the web UI allows a Jenkins administrator to
enable, configure, or disable key security features which apply to the entire
Expand Down