Struggling to find cloud security expertise?

Our dashboards correlate events across the multi cloud and on-premise, Reduce resolution time time by 95%

Start Risk Assessment

Webinar

AI-LLM-webinar-card
1/4

eBook

ebook

Get eBook worth $199 for Free

DOWNLOAD NOW
2/4

Blog

mssp

Why AccuKnox is the most MSSP Ready CNAPP?

LEARN MORE
3/4

Comparison

Comparison

Searching for Alternative CNAPP?

COMPARE NOW
4/4
securing jenkins featimg

Securing Jenkins – Mitigating CVE-2024-23897 with AccuKnox

 |  November 21, 2024

Here’s a step-by-step guide to simulating an attack on Jenkins, exploiting CVE-2024-23897, and mitigating it using AccuKnox Runtime Security.

Reading Time: 3 minutes

As enterprises scale their DevOps pipelines, continuous integration tools like Jenkins are vital, but securing them is crucial. In this blog, we’ll walk through a step-by-step guide to simulating an attack on Jenkins, exploiting CVE-2024-23897, and mitigating it using AccuKnox Runtime Security.

The newly discovered vulnerability, CVE-2024-23897, affects Jenkins CLI and exposes a critical flaw that could allow remote attackers to access arbitrary files and potentially escalate privileges. Discovered in Jenkins 2.441 and earlier, including LTS 2.426.2, the flaw is actively being addressed to mitigate risks.

This critical security issue arises from Jenkins’ command-line interface (CLI) feature, which uses the args4j library for argument parsing. When processing CLI commands, Jenkins enables expandAtFiles, which automatically replaces an @ character followed by a file path in command arguments with the file’s contents. Since this function is enabled by default in Jenkins, it introduces a critical risk: any user accessing Jenkins’ CLI could read arbitrary files from the system by including a @ symbol followed by the target file path in their commands.

Severity: Critical (CVSS 9.8/10)
Affected Versions: Jenkins 2.441 and earlier, LTS 2.426.2 and earlier
Root Cause: Improper argument parsing in Jenkins CLI
Potential Impact: Arbitrary file read and remote code execution

If an attacker gains access to sensitive files, they may escalate their privileges, gaining unauthorized access to additional data or systems. This vulnerability could be exploited to read configuration files, credentials, or other critical information, ultimately allowing the attacker to compromise Jenkins’ functionality and the security of applications deployed via Jenkins.

Simulating the Attack in a Kubernetes Cluster

To demonstrate the impact of CVE-2024-23897, we’ve deployed Jenkins (version 2.441) to a Kubernetes (K8s) cluster.

securingJenkins 1
securingJenkins 2

With Jenkins up and running, we will exploit CVE-2024-23897 to attempt to read the /etc/passwd file, a typical reconnaissance step used by attackers to gain insights into system users. We will use the exploitation proof-of-concept (PoC) script. You can find the PoC script and detailed instructions at this link.

python3 CVE-2024-23897.py --url http://172.16.250.135:32000 -f /etc/passwd
securingJenkins 3

After sending the crafted request, we observe a partial output of the /etc/passwd file, demonstrating unauthorized data exposure as anticipated.

Defend with AccuKnox Runtime Security

AccuKnox Runtime Security provides powerful, real-time protection against unauthorized or malicious activities by enforcing security policies directly in your environment. By integrating AccuKnox’s policies, you can proactively block exploitation attempts and secure sensitive files from unauthorized access.

Let’s walk through the steps to protect Jenkins from such attacks using AccuKnox Runtime Security:

  1. Ensure AccuKnox Runtime Security is Configured

Verify that AccuKnox Runtime Security is installed and configured on your Kubernetes cluster to enable security enforcement.

  1. Navigate to Policies

In the AccuKnox dashboard, go to the Policies section under the Runtime Security tab.

securingJenkins 4
  1. Upload or Edit a Policy for Jenkins

Upload a pre-configured policy or use the policy editor to create a custom policy for Jenkins. And activate the policy.

securingJenkins 5

This policy will be configured to block access to sensitive files such as /etc/passwd, /etc/shadow, and system logs, preventing unauthorized access.

apiVersion: security.kubearmor.com/v1
kind: KubeArmorPolicy
metadata:
  name: jenkins
  namespace: demo
spec:
  action: Block
  file:
    matchDirectories:
    - dir: /etc/ssh/
    matchPaths:
    - path: /etc/passwd
    - path: /etc/shadow
    - path: /var/log/auth.log
    - path: /var/log/wtmp
    - path: /var/run/utmp
  message: Access sensitive files detected
  selector:
    matchLabels:
      app: jenkins
  severity: 1

This policy ensures that any attempt to read or modify sensitive files by unauthorized sources is immediately blocked.

Once AccuKnox Runtime Security policies are applied, the same attempt to access /etc/passwd is blocked. AccuKnox effectively prevents unauthorized access to sensitive files, ensuring that Jenkins remains secure against such exploits.

securingJenkins 6

After the policy enforcement, an alert is triggered in the AccuKnox SaaS dashboard, notifying us of the blocked access attempt. The alert provides detailed information about the blocked activity, including the source of the request and the path of the sensitive file that was protected.

securingJenkins 7

By using AccuKnox Runtime Security, you achieve real-time protection and prevent unauthorized file access, safeguarding Jenkins against potential exploitation.

You can protect your workloads in minutes using AccuKnox, It is available to protect your Kubernetes and other cloud workloads using Kernel Native Primitives such as AppArmor, SELinux, and eBPF.

Let us know if you are seeking additional guidance in planning your cloud security program.

Ready for a personalized security assessment?

“Choosing AccuKnox was driven by opensource KubeArmor’s novel use of eBPF and LSM technologies, delivering runtime security”

idt

Golan Ben-Oni

Chief Information Officer

“At Prudent, we advocate for a comprehensive end-to-end methodology in application and cloud security. AccuKnox excelled in all areas in our in depth evaluation.”

prudent

Manoj Kern

CIO

“Tible is committed to delivering comprehensive security, compliance, and governance for all of its stakeholders.”

tible

Merijn Boom

Managing Director

Please enable JavaScript in your browser to complete this form.