Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Local Code Inclusion
Cyber Security

Local Code Inclusion

← Back to Glossary
By NHI Mgmt Group Updated October 17, 2026 Domain: Cyber Security

Local Code Inclusion is a vulnerability where an application includes and executes code from a file already present on the local system. Attackers abuse unsafe file inclusion paths, upload locations, or writable directories to run unexpected code. Defenders should restrict include paths, validate file references, and prevent user-controlled files from being executed.

How Local Code Inclusion Works

Local code inclusion happens when an application is persuaded to load and execute code from a file already on the server. The file may be a legitimate application file, a previously uploaded file, or content placed in a writable directory that the runtime later treats as executable.

That makes the issue more dangerous than a simple read bug. If the application can be steered toward an attacker-influenced path, the inclusion step can turn file placement into server-side code execution, especially in scripting environments where include semantics and execution semantics overlap.

Why It Becomes Exploitable

Exploitation usually depends on a weak trust boundary around file names, paths, or upload handling. Unsafe include logic, broad writable directories, and loose validation can let user-controlled content become executable just because it sits in a location the application already trusts.

Attackers often look for code paths that build file references from request parameters or configuration values. When path control is possible, the application may include content that was never intended to be part of its trusted code base, which can expose session data, server-side secrets, or administrative functionality.

For a practical threat view, the broader web application attack landscape in NHIMG’s Web Application Attacks Guide helps place local code inclusion alongside other inclusion and injection failures.

How Organisations Check Exposure and Reduce Blast Radius

Exposure review starts with identifying which directories can be written to, which files are reachable by include logic, and whether application components ever accept file paths directly from users. Review vendor guidance, deployment templates, and file upload handling together, because the weakness often appears in the interaction between them rather than in one isolated function.

Hardening usually means narrowing include paths to known-safe locations, separating upload storage from executable content, and blocking any workflow that can convert user-supplied files into runtime code. If a system must accept arbitrary file names, the application should resolve them against an allowlist of approved locations rather than trusting raw path input.

These controls line up with standard access and integrity expectations in NIST SP 800-53 Rev 5 Security and Privacy Controls, especially where execution integrity and access restriction are part of the design.

Detection, Review, and Recovery After Suspected Abuse

Detection should focus on unusual file creation, unexpected include targets, and code execution from locations that normally hold uploads, caches, or temporary files. Logs that show repeated path probing, odd extensions, or include failures followed by a successful execution attempt are especially useful.

After suspected exploitation, teams should assume the attacker may have altered application files, added a web shell, or planted a second-stage payload in a writable directory. A post-incident review should verify which files were created or modified, whether execution permissions were too broad, and whether the application ever loaded code from a location outside its intended trust boundary.

Because the pattern overlaps with other web execution and file-handling failures, the OWASP API Security Top 10 is useful only as a companion reference for trust-boundary thinking, while local code inclusion itself remains a web application file-inclusion problem.

Risk and Threat Considerations

Local code inclusion is dangerous because it can convert a file handling flaw into code execution, often with the same privileges as the application process. Once an attacker can influence an include path or place a file in an executable location, the issue can become a direct path to persistence, data theft, or further server compromise.

Failure mechanism: The application trusts a local file reference that the attacker can influence, then executes that file as code instead of treating it as inert content.

Impact: The attacker may gain server-side execution, modify application behaviour, read sensitive data, drop additional payloads, or use the host as a foothold for broader compromise.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationLocal code inclusion often begins with untrusted file-path input that must be constrained.
AC-6 — Least PrivilegeExecution from writable locations becomes far more dangerous when the process has excess access.
Recommendation — Validate file references and reject user-controlled paths before they can influence code inclusion. Limit the application process to only the file and directory access it truly needs.
OWASP ASVSV15 — Secure Coding and ArchitectureThe term concerns insecure file inclusion logic and trust-boundary design in application code.
Recommendation — Design include and upload flows so untrusted content cannot become executable code.
CIS Controls v8CIS-16 — Application Software SecurityThis issue is an application security failure tied to unsafe inclusion and file handling.
Recommendation — Review application code and deployment paths for unsafe file inclusion and executable uploads.
MITRE ATT&CKT1059 — Command and Scripting InterpreterSuccessful exploitation frequently ends in server-side code execution through a scripting interpreter.
Recommendation — Hunt for interpreter-driven execution from unexpected local file paths and upload locations.

Practitioner Guidance

Why practitioners should care: Local code inclusion is rarely just a bug in one function, it is often a sign that file handling, deployment layout, and execution permissions were designed without a strict separation between content and code. That separation is the core control to protect.

What to watch for: Pay close attention to user-controlled path handling, upload destinations, temporary directories, and any component that transforms file names into executable includes. If those areas are reachable from the network, they deserve the same scrutiny as direct code execution paths.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 17, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org