Lets get started with Defense.
Defense for Administrators/Users
- No build agent/executor should run on the master EVER. If the CI tool you use installs it by default (see the Common Abuse Set in Day 4), keep a strict control over which project or build can use the agent on master. If there are certain cases where you require agent on maser, try to eliminate those requirements by all means.
- Ability to Configure builds should be very restricted. Ask yourself, if you will you provide Local Administrator access to all the executors/agents machines tied to a project to a user.
- Make sure that agents are pooled for projects. No project should be allowed to use arbitrary agents.
- Jenkins: NodeLabel Parameter Plugin and Job Restrictions Plugin.
- TeamCity: Agent Pools.
- Go: Environments
- Secure the Administrator web console/dashboard.
- Make sure to enable Authentication and use complex passwords (at least) for Admin users, even if the tool runs only internally.
- Enable HTTPS.
- Consider integration with Active Directory for authentication. Please make sure to weigh pros and cons specially if your CI tool is exposed to the internet.
- Ask your users to not use their username as passwords.
- Try not to expose your CI Tool to the Internet (unless you want to show to the World how your developers leave sensitive data in build logs). VPN anyone? (You may also like to experiment with things similar to Jenkins’ Google or OpenID login plugins)
- Do NOT provide even read access to Anonymous users (unless, once again, you want to show to the World how your developers leave sensitive data in build logs).
- Ask your Red Team or Penetration Testers to specifically target your CI tool.
Defense for Tool Developers
- Enforce password policies (complexity, expiry, captcha on login failures etc.)
- A user must install agent/slave explicitly on the master. Do not include it in the install package. Show big red warning regularly if an agent/slave is installed on the master.
- Please, puppy please, do not store credentials and keys in clear text on master (or anywhere else).
- Assume that your users don’t know a thing about security. Make your tool at least reasonably secure in the default installation. IMHO, because “default just works”, the level of security in a default installation is what one finds in majority of installations. You can learn from each other, for example:
- When TeamCity can enable authentication in the default installation, why can’t Jenkins and Go?
- When Go does not install an agent on master in the default install, why can’t Jenkins and TeamCity? and so on.
- Explore the possibility of running as a non-SYSTEM or admin on Windows installations.
Response to those who reported things (and those who didn’t)
- Response: “this is just something to be documented” Status: Not done yet.
- Response: “How is this NOT obvious?” Because it is not well documented.
Those who tried to report issues: http://www.th3r3p0.com/vulns/jenkins/jenkinsVuln.html
- “acknowledge that the Jenkins admins have the power to access all of these credentials and don’t make unstrusted people admins”
- “But admins are admins”
- “For obvious reasons, that’s a bad idea” – Exactly my point.
- “for it to be considered a pen test, I’d have expected it to be more thorough and trying different attacks” – The Trivial Attack Syndrome.
Free Advice: Dealing with security issues reported/not reported.
- “If its admin its game over” is so 90s. Move on. Try to minimize lateral propagation and post exploitation.
- Once again, the default security is the security you will find in majority of installs.
- Don’t try to be dismissive of the reports. If you will be dismissive, potential issue raisers will just move on.
- FFS, improve documentation. It is not enough to mark issues as “obvious” in comments. Make it look obvious in the documentation.
- All reported/not reported issues will not be 0 days. There will be issues which are critical enough but do not provide unauthenticated remote code execution. Understand that various low and medium severity issues are chained together for compromise.
- Repeat with me, trivial attacks are more dangerous, trivial attacks are more dangerous, trivial attacks…
Why I don’t do “Responsible Disclosure”
Getting 0wned due to CI Tools
- “The Jenkins project has received multiple credible reports indicating that unsecured, publicly accessible instances of Jenkins are being targeted and infected with malware” – https://wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2015-10-01
- Facebook used to run an unauthenticated Jenkins instance – http://blog.dewhurstsecurity.com/2014/12/09/how-i-hacked-facebook.html
- “We got hacked. We were running a (unauthenticated) Jenkins instance in this machine.” https://plumbr.eu/blog/plumbr-blog/we-got-hacked
- “LANDESK has found remnants of text files with lists of source code and build servers that the attackers compiled,” John said. “They know for a fact that the attackers have been slowly [archiving] data from the build and source code servers….” – http://www.krebsonsecurity.com/2015/11/breach-at-it-automation-firm-landesk/
Previous Work
What we didn’t discuss?
- Master<->agent communication and MITM attacks.->
- Compromising integrity of the source code and the build process.
- Web application related vulnerabilities of web consoles.
- Memory corruption bugs.
- Logging process and issues.
To support my research, join me for a two days training “PowerShell for Penetration Testers” at:
BlackHat, Asia (March 29-30th, 2016) – https://www.blackhat.com/asia-16/training/powershell-for-penetration-testers.html
HITB, Amsterdam (May 24-25th, 2016) – http://conference.hitb.org/hitbsecconf2016ams/sessions/2-day-training-3-powershell-for-penetration-testers/