A script runs on a developer’s workstation, accesses stored credentials and connects to an external server. An endpoint detection and response alert is raised, and the security team must determine what happened: Was the activity malicious? Were credentials exposed? Did the script affect other systems?
These questions become harder when the code is unfamiliar. Generative AI can help attackers create and modify malicious software, while developers increasingly use it to write legitimate scripts, tests and applications. A security team may encounter new code from both sources, and unfamiliarity alone is not enough to determine whether it is dangerous.
The more useful question is what happens before that code runs. When a script or package has access to credentials, build systems or deployment infrastructure, a runtime alert may arrive only after sensitive resources have already been exposed.
This makes pre-execution security an important part of the development workflow. It helps teams assess code, enforce policies and limit access before potentially risky activity begins, while runtime monitoring remains essential for detecting behavior that earlier checks cannot identify.
Unfamiliar code creates more decisions for security teams
Security alerts are often discussed in terms of volume: how many arrive and whether the team has enough people to investigate them. But the difficulty of each decision matters just as much.
An analyst may need to determine what a file is, what it can do, whether it has already run and whether the activity should be contained. The same code can require very different responses depending on where it runs.
A suspicious script in an isolated test environment may present limited immediate exposure. A similar script running in a build environment with access to cloud credentials, signing keys or deployment permissions requires a more urgent and detailed investigation.
AI adds another dimension. Attackers can use it to produce variations of malicious code, potentially making detection based on known files or signatures less effective. At the same time, a new file hash does not necessarily indicate a new attack technique: different files may still behave in similar ways.
Behavioral detection remains valuable for that reason. The challenge is reducing the number of cases in which analysts must reconstruct events after unfamiliar code has already reached a sensitive environment.
Risk scores need clear policies behind them
Security tools often use risk scores to help teams prioritize alerts. This is useful in environments where signals are incomplete and the same activity can be benign in one context and suspicious in another.
But a score alone does not define what should happen next. Organizations need policies that connect the evidence to an action: allow execution, restrict permissions, block the activity or require a review.
Those decisions should account for both the code and the environment. A script requesting access to a temporary development sandbox does not carry the same potential impact as one requesting access to production credentials.
Clear enforcement rules also make decisions easier to explain. Teams should be able to identify which evidence and policy led to an allow or block decision, apply comparable treatment to comparable cases and document exceptions when the context justifies them.
Once code runs, the investigation gets bigger
Before execution, a review can focus on questions such as where the code came from, what it appears designed to do and what access it needs.
After execution, the investigation expands. Analysts may need to determine whether the code accessed credentials, communicated with an external system, established persistence or affected other machines. Even if they find no compromise, establishing that conclusion takes time.
Development workflows can increase the potential exposure. Package installation scripts, for example, may execute with the permissions of the account installing them. Similarly, an AI-generated script run by a privileged service account may inherit access to credentials, infrastructure or deployment systems.
Runtime detection and containment can limit the impact of malicious activity. But they do not eliminate the need to investigate what happened before the alert was raised.
Build security into the workflow before execution
A practical starting point is to identify where unfamiliar code enters or runs in the development process. This may include downloaded scripts, AI coding agents, third-party packages and continuous integration and delivery pipelines.
For each workflow, teams should understand which account executes the code, what resources it can access and whether those permissions are necessary for the task.
Depending on the context, pre-execution controls can include:
- Checking the source and provenance of code and dependencies before introducing them into sensitive environments.
- Reviewing code and installation behavior, particularly when it can access credentials, change system configuration or communicate externally.
- Testing in an isolated environment when the behavior or origin of the code requires further assessment.
- Applying execution policies that restrict what can run in privileged or production environments.
- Limiting permissions so that code and the accounts running it can access only the resources required for their work.
These controls will not reveal every action a program may take. Some behavior becomes visible only during execution, which is why endpoint monitoring, detection and response remain necessary.
Security needs to support delivery
The goal is not to slow development every time a new script or dependency appears. It is to make decisions earlier, with enough context to protect sensitive systems without creating unnecessary friction.
Teams can assess whether their controls are working by looking at investigation time, false blocks and the effect on legitimate development workflows. If a control consistently delays routine work without reducing meaningful risk, it may need to be refined.
AI can increase the speed at which code is created and introduced into an environment. Security processes need to keep pace: reviewing what runs, controlling the access it receives and monitoring what it does once execution begins.
We have helped 20+ companies in industries like Finance, Transportation, Health, Tourism, Events, Education, Sports.