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

Malicious Code

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

Code deliberately written to perform unauthorized or harmful actions inside software, scripts, dependencies, or build assets. It is narrower than malware because it focuses on the code layer that gets embedded into applications and delivery pipelines, where it can steal data, open backdoors, or alter system behavior.

How malicious code differs from broader malware

Malicious code is the code layer of an attack: deliberately crafted source, script, dependency, template, or build artifact that behaves in an unsafe way once it is executed, imported, or compiled into a trusted system. That narrower focus matters because the risk often begins before a full malware payload exists, inside software delivery, reuse, or integration workflows.

Unlike broad malware categories, malicious code is often embedded where defenders expect legitimate development activity. It can hide in application logic, package installs, build scripts, CI jobs, test fixtures, browser extensions, or reusable components, which makes provenance and trust boundaries part of the security problem.

Where malicious code enters software systems

The most common entry points are places where code is copied, reviewed, or executed automatically: repositories, dependency managers, build pipelines, release automation, internal package feeds, and developer workstations. A single poisoned dependency or tampered script can propagate into many downstream systems if it is reused widely.

That is why supply-chain compromise is such a recurring pattern. The malicious logic is not always a standalone binary; it can be a few lines inserted into a package install hook, a compromised action, a build-time helper, or a script that quietly changes what later stages deploy. reviewdog Action compromise 2025 is a useful example of how a trusted development component can become a delivery path for secret theft and further compromise.

Security consequences of embedded malicious code

The main danger is that the code runs with the privileges and trust of the application, pipeline, or developer environment that consumes it. Once inside that trust boundary, malicious code can steal data, alter outputs, create backdoors, disable checks, tamper with logs, or stage a second payload for later execution.

Because it rides on legitimate execution paths, malicious code is often hard to distinguish from normal behavior until after damage begins. Defenders should think about code integrity, provenance, execution permissions, and output validation together, not as separate problems. Code Signing Security Guide is especially relevant here because code signing, when properly protected and validated, helps reduce the chance that altered code is treated as trusted software.

How defenders reduce exposure to malicious code

The practical defence is to shrink the set of places where untrusted code can enter, run, or persist. That means tighter control over dependencies, build inputs, extension ecosystems, repository changes, and signed artifacts, plus review of any automation that can modify code or release output.

Detection should focus on integrity breaks, unexpected execution paths, and suspicious changes to build or install behavior. ATT&CK Execution Tactic Guide helps defenders map code-driven abuse to execution behaviours, while GlassWorm VS Code Extension Worm Guide shows how malicious code hidden in developer tooling can spread through trusted workflows.

Risk and Threat Considerations

Malicious code is high-risk because it exploits trust in the software lifecycle itself. The code may look legitimate at review time, but once executed it can pivot from a minor change to data theft, persistence, or release tampering across many systems.

Failure mechanism: Attackers insert or alter code at a point where it will later be executed automatically, such as a dependency, script, build step, or extension, then use that trusted execution context to perform unauthorized actions.

Impact: The result can be secret exposure, unauthorised access, backdoors, corrupted releases, and downstream compromise of users, build systems, or production environments.

Standards & Framework Alignment

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

NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5SI-3 — Malicious Code ProtectionDirectly addresses detecting and blocking malicious code in systems and pipelines.
SI-7 — Software, Firmware, and Information IntegrityFits integrity controls for code, builds, and released artifacts that malicious code targets.
SA-11 — Developer Testing and EvaluationSupports secure evaluation of code and components before release into trusted environments.
Recommendation — Apply SI-3 to scan, block, and quarantine malicious code before execution or deployment. Use SI-7 to verify code and artifact integrity before they are trusted or run. Use SA-11 to test and evaluate code for hidden malicious behavior before release.
CIS Controls v8CIS-16 — Application Software SecurityCovers controlling software integrity and unsafe code in the application lifecycle.
Recommendation — Adopt CIS-16 to govern software integrity checks and reject unsafe code changes.
OWASP ASVSV15 — Secure Coding and ArchitectureApplies where malicious code is introduced through insecure application design or code handling.
Recommendation — Use V15 to reduce the chance that hostile code paths are introduced into software design.

Practitioner Guidance

Why practitioners should care: Treat malicious code as a provenance and execution problem, not only a malware problem. The key question is whether the code can be trusted to run in the place and with the permissions it is about to receive.

Governance implication: Ownership should span development, security, and release operations, because the control failure may happen in review, dependency intake, CI/CD, or artifact publication rather than in the final application alone.

Practitioner takeaway: The strongest controls are the ones that stop untrusted code from becoming trusted code in the first place, and that preserve the evidence needed to prove what actually ran.

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 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org