SA: Chapter 5
The Critical Need for Dependency and Infrastructure Management
The Fragility of Modern Digital Infrastructure
Modern digital systems rely on a vast web of interdependencies. A famous example is the leftpad.js incident, where one programmer disrupted web development worldwide by deleting a tiny piece of code ( lines long).
leftpad.js Code Structure:
A significant portion of modern infrastructure is thanklessly maintained by random individuals (e.g., a project maintained by someone in Nebraska since ).
Security and Compliance Risks
Heartbleed Bug: A catastrophic bug in the OpenSSL 'heartbeat' function placed hundreds of thousands of servers at risk, potentially leaking user details and passwords.
Infrastructure Misconfiguration: Insecure Amazon S3 bucket permissions (e.g., set to "AllowPublicRead" with
"Principal": {"AWS": "*"}) can allow anyone to upload or view data. These exposures are often triggered by accidental changes to database system permissions.Licensing: Organizations must constantly verify if they are complying with all software licenses within their dependency chain.
Strategic Outline for Management
Dependency Management: Handled via Software Composition Analysis (SCA).
Infrastructure Management: Handled via Infrastructure as Code (IaC).
Compliance Management: Handled via Policy as Code (PaC).
Dependency Management and Software Composition Analysis (SCA)
The Scale of Modern Ecosystems
Dependency files (e.g., Maven's or Node's ) list external libraries required by a project.
Ecosystem Growth: The number of indexed artifacts in repositories like Maven Central and npm has grown exponentially, reaching millions of projects and tens of millions of indexed artifacts by .
Analysis of Vulnerabilities (npm and RubyGems)
Top 10 Vulnerability Types (npm):
Malicious Package:
Directory Traversal:
Cross-site Scripting (XSS):
Resource Downloaded over Insecure Protocol:
Regular Expression Denial of Service (ReDoS):
Denial of Service (DoS):
Prototype Pollution:
Command Injection:
Arbitrary Code Execution:
Arbitrary Code Injection:
Patching Trends:
of disclosed vulnerabilities are fixed in patch releases.
Severity does not significantly impact the release type (major, minor, or patch) used for a fix.
Time Lag: of vulnerabilities take over months to find and fix. In RubyGems, this can take up to months.
Impact Sphere: A disclosed vulnerability affects a median of package releases. A single vulnerable package release can expose a median of dependent packages, with a maximum exposure of packages ( of the ecosystem) observed in npm.
The Risk of Dormant Packages (EMSE 2025 Research)
Dormancy Definition: A period of inactivity in package releases. We observed release gaps in high-quality npm packages.
Key Statistics:
Median time between versions before a gap: days (indicating active maintenance).
Median gap duration: months (ranging from months to years).
Resumption: Nearly half of dormant packages resume with a patch release, often focusing on configuration, dependency specification, and documentation. Specifically, of resumed packages modify .
Security Implications: During a dormancy gap, the proportion of outdated dependencies increases from to . Even after a gap is closed, of revived packages remain exposed to known vulnerable dependencies ( CWE-400: Uncontrolled Resource Consumption; CWE-79: XSS).
Advanced SCA Recommendations: "Go Deep" and "Go Broad"
Recommendation 1: Go Deep (Reachability Analysis)
Problem with Shallow SCA: Many tools provide a "shallow" metadata scan (
npm audit). These often result in high false-positive rates because they do not check if the vulnerable code is actually reachable or exploitable.Pain Points of Program Analyzers: Developers cite too many false positives ( precision in some cases), complexity, and lack of suggested fixes as major obstacles.
Reachability: Deeper analysis must trace the call graph from the application's entry points () to the specific vulnerable function () in the external package (). If the vulnerable code is not reachable, the vulnerability is not exploitable.
Recommendation 2: Go Broad (Scanning Containers and Orchestration)
Container Scanning: Docker images often inherit vulnerabilities. A study of top- images showed they contain a median of npm vulnerabilities.
Docker Inheritance: Images built
FROMbase images (likenode:16) inherit all layers and vulnerabilities from those parents. Detection based on Dockerfiles is unreliable because tags are pointers that change; layer content hashes provide better identification.Helm Chart Risks (Kubernetes): SCA must extend to orchestrators. Research on charts found:
of deployed images were already outdated upon the chart's release.
of charts deploy known vulnerabilities.
Specific exposures included Log4Shell ( charts) and Spring4Shell ( charts).
Infrastructure Management via Infrastructure as Code (IaC)
The Complexity of Modern Deployment
Infrastructure involves provisioning, configuring, and managing diverse components: Firewalls, Load Balancers (WWW), Applications, and Databases across multiple environments (Development, Acceptance-Testing, Beta, Production).
Defining IaC
Automation: IaC enables the automation of infrastructure setup through executable scripts (e.g., Ansible, Terraform, Chef, Puppet).
Ansible Example:
Task: A single step ( "Configure user account").
Module: Configures specific platform parts (
user).Module Arguments: Define the desired state (
name: "admin").
Security Weaknesses in IaC
Hardcoded Secrets: Embedding plain-text passwords in scripts. This can be mitigated using tools like Ansible-vault to encrypt secrets within the source code.
Security Smells:
HTTP without SSL/TLS.
Missing integrity checks for downloads.
Unrestricted bind addresses ().
Weak cryptographic algorithms.
Empty passwords.
Detecting Weaknesses through Graphs (GASEL Tool)
Shallow tools miss weaknesses involving expressions () or cross-file data flows ().
GASEL (Graph-based Ansible SEcurity Linter): Uses Program Dependence Graphs (PDG) and graph queries to track variables across files and roles. In benchmarks against tools like SLAC and GLITCH, GASEL achieved significantly higher precision and recall for smells like "Missing Integrity Check" and "Weak Crypto Algorithm."
Predicting Secrets and the Deployment Supply Chain
Machine Learning for Secret Detection
Many developers forget to add
no_logannotations to sensitive parameters. Machine Learning (ML) and Language Models (LM) can analyze module documentation to predict if a parameter is secret.Research Findings:
Traditional ML (Random Forest): precision but limited recall.
Fine-tuned LM (Transformer-based): Achieved nearly perfect precision and recall () by understanding the semantic context of documentation (distinguishing, for instance, between public and private keys).
The Extensive IaC Supply Chain
Deployment code has its own supply chain: Playbooks depend on Roles, which depend on Modules. Modules, in turn, depend on Python packages, OS binaries, and language runtimes.
SCA for Deployment Code: Automated logic is required to extract informal and unstructured dependency specifications from plugin implementations to generate Software Bills of Materials (SBOMs).
Compliance Management via Policy as Code (PaC)
Definition and Guardrails
PaC sets organizational and technical "guardrails" through machine-enforceable code. Examples include: "All S3 buckets must be private" or "Cloud budget max /month."
PaC Tools and Examples
Open Policy Agent (OPA): General-purpose; uses Rego language to deny actions (e.g., blocking non-senior engineers from merging to
main).Kyverno: Kubernetes-native; enforces cluster policies via YAML.
HashiCorp Sentinel: Used for Terraform; validates provisioned resources (e.g., ensuring S3 public access blocks are enabled).
Taxonomy of Policies
Infrastructure and Security Policies: Cloud Utilities (), Virtualization (), General Security ().
Operational Policies: Monitoring (), Software Development/PRs (), SQL (), Networking ().
Rare Categories: Intellectual Property, Expenses, Metadata.
Maintenance and Adoption
PaC files are typically small (median non-empty lines).
Once introduced, PaC requires very little maintenance (median frequency of changes is near zero), making it a highly efficient method for long-term security and compliance enforcement.