
SQL injection — example and mitigation
SQL injection occurs when untrusted input is used to construct SQL statements, allowing an attacker to change the intended query logic. The following naive example demonstrates building a query by concatenating strings:-- begins a SQL comment, causing the password check to be ignored and making the WHERE clause evaluate to true. This can allow authentication bypass or data exfiltration.
Key mitigations
- Use parameterized queries / prepared statements instead of string concatenation.
- Validate and sanitize input early (whitelisting preferred over blacklisting).
- Apply least-privilege on database accounts (avoid granting broad SELECT/DDL privileges).
- Add runtime protections such as web application firewalls (WAFs) and database activity monitoring.
Always prefer parameterized queries / prepared statements over string interpolation when building SQL queries. Static analysis catches risky patterns early, but runtime protections and least-privilege database access are essential additional layers.
SonarQube and static analysis
Static Application Security Testing (SAST) tools analyze source code for risky patterns and suggest remediations. SonarQube is a widely used example that flags unsafe database calls, unsanitized inputs, insecure deserialization, and other common code smells that lead to vulnerabilities.- Integrate SAST into your CI pipeline so findings are reported on every pull request.
- Triage SAST findings by severity and remediation effort (fix high-severity issues first).
- Combine SAST with secure coding checklists and code review policies.

Dependency management and software composition analysis (SCA)
Third-party libraries and transitive dependencies are a common source of vulnerabilities. Software Composition Analysis (SCA) tools and dependency scanners enumerate dependencies, correlate them with vulnerability databases (e.g., NVD), and surface version-specific CVEs so you can remediate or apply mitigations. Minimal application example that pulls in multiple third-party packages:- Run dependency scans in CI to fail builds on critical/high severity CVEs.
- Automate patching or update PR creation for vulnerable libraries.
- Use dependency restrictions (e.g., allowlists) and lockfiles to stabilize dependency versions.
Log4j (Log4Shell) — a runtime-exploited library vulnerability
Log4j (a Java logging library) contained a critical remote code execution vulnerability (Log4Shell) that could be triggered when certain user-controlled strings were logged. Because the exploit leveraged a runtime lookup feature, many early static scans and naive dependency checks missed the issue. Vulnerable logging usage example:- Not all vulnerabilities are detectable by static dependency checks; some are triggered only at runtime.
- Maintain an accurate inventory of libraries and their versions.
- Have an emergency patching and mitigation plan for widely used runtime libraries.
Runtime monitoring and behavioral detection
Runtime detection and monitoring are necessary to observe real exploit attempts and anomalous behaviors that static analysis cannot detect. Application Security Monitoring (ASM), Runtime Application Self-Protection (RASP), and cloud-native runtime security platforms can detect suspicious activity and trigger alerts or automated responses. Examples of runtime coverage:- Detect anomalous outbound connections originating from app processes (indicator of data exfiltration).
- Monitor for unexpected system calls or code execution patterns.
- Correlate logs, traces, and metrics to identify exploitation attempts.
Keep third-party libraries up to date. Runtime monitoring detects active exploitation, but timely patching, vulnerability management, and incident response procedures are critical for preventing large-scale incidents like Log4Shell.
Container-level visibility and troubleshooting
Mapping application behavior to container and kernel-level activity is important for both performance troubleshooting and security investigations. Tools that provide deep visibility into containers can reveal which processes consume resources, trace system calls, and surface anomalous activity for investigation. Sysdig provides container- and host-level visibility, enabling:- Live process and network tracing inside containers.
- Detection of unusual process behavior or resource spikes.
- Forensic analysis combining system call data and container metadata.

Summary and recommended practices
- Secure coding: Use parameterized queries, validate input, and avoid insecure patterns.
- SAST in CI: Integrate static analysis to catch risky code early in the development lifecycle.
- SCA and dependency management: Scan dependencies for CVEs, automate fixes, and maintain inventories.
- Runtime protections: Use monitoring, behavioral detection, and runtime policy enforcement to detect exploitation.
- Patch and response: Prioritize timely patching, emergency mitigation plans, and incident response playbooks.
- Least privilege: Apply the principle of least privilege to databases, services, and runtime identities.
- SonarQube — https://www.sonarqube.org/
- Veracode — https://www.veracode.com/
- Codacy — https://www.codacy.com/
- Snyk — https://snyk.io/
- OWASP Dependency-Check — https://owasp.org/www-project-dependency-check/
- OWASP Dependency-Track — https://dependencytrack.org/
- Apache Log4j security — https://logging.apache.org/log4j/2.x/security.html
- Sysdig — https://sysdig.com/