Jenkins is an open-source automation server used to automate software building, testing, and deployment through Continuous Integration and Continuous Delivery (CI/CD) pipelines. A Jenkins pipeline defines a sequence of operations, such as checking out source code, installing dependencies, executing build commands, running security tests, and preparing application artifacts.
The Jenkinsfile defines the pipeline configuration and its build stages. If an attacker modifies a Jenkinsfile or introduces an unauthorized command into a build stage, the pipeline may execute suspicious operations within the permissions and environment available to the Jenkins agent.
Malicious build-step injection may involve unexpected shell commands, unauthorized script downloads, suspicious command chaining, or attempts to access sensitive files and environment variables. Such behaviour can compromise build integrity, expose credentials, or affect the security of generated software artifacts.
In this use case, Jenkins is deployed on an Ubuntu virtual machine in an isolated VirtualBox laboratory. Controlled pipeline configurations are maintained in a Git repository, and harmless normal and suspicious build-step examples are prepared for testing. A publicly available cybersecurity dataset containing relevant command or script-behaviour records is also used for model development and evaluation. The selected dataset must provide features that can be mapped meaningfully to the behavioural features extracted from Jenkins build steps.
Python is used to process the public dataset, extract relevant features, and prepare structured data for analysis. The Local Outlier Factor (LOF) algorithm analyses the local density of feature vectors and identifies build steps that differ significantly from their surrounding behavioural patterns. Dataset preprocessing and feature compatibility checks are performed before the model is applied to Jenkins pipeline data.
The public dataset supports model development and evaluation, while controlled Jenkins pipeline test cases are used to assess the detection workflow in the target environment. Dataset records are not assumed to represent Jenkins-specific attacks automatically; only relevant records and compatible features are used. The limitations of applying dataset-derived patterns to Jenkins build steps are documented.
The proposed system does not assume that every unusual command is malicious. LOF generates anomaly scores, and the detected build steps are reviewed against security rules and the expected pipeline configuration before a security decision is made.
Semgrep CE provides supplementary static analysis for supported source code and security patterns. Gitleaks checks the repository for potential hardcoded secrets, while Trivy examines supported container images and configuration files for known vulnerabilities and security misconfigurations. These tools complement the primary AI-based detection mechanism rather than replacing it.
Docker is used where required to isolate controlled build execution. A Python-based Streamlit dashboard presents detected anomalies, affected pipeline stages, relevant indicators, security findings, and assessment results.
When a suspicious build step is confirmed, Jenkins pipeline controls are used to prevent the affected build from proceeding. The build configuration is reviewed, the unauthorized command is removed or corrected, and the pipeline is executed again to validate the remediation.
The complete security-validation workflow is:
Public Cybersecurity Dataset Collection
→
Dataset Inspection
→
Data Preprocessing
→
Feature Engineering
→
Dataset-Based LOF Model Development
→
Jenkinsfile Collection
→
Build-Step Feature Extraction
→
Anomaly Detection
→
Security Rule Validation
→
Risk Assessment
→
Build Execution Control
→
Script Remediation
→
Post-Remediation Validation