InfiniteLoopRule and ResourceExhaustionRule are part of the AgentScript preset only). Each rule can be configured and combined to match your security requirements. This page covers the ones a host is most likely to configure itself; the AgentScript preset combines them for LLM-generated code.
NoGlobalAccessRule
Blocks access to the global objects, toconstructor, to the Reflect API and to the reflection statics of Object.
window.locationglobalThis['Function']thisas a value in any position, when'this'is inblockedGlobals:const g = this,f(this),const { x } = this. The STRICT and SECURE presets refuse it this wayObject.create,Object.defineProperty,Object.getPrototypeOfand the other prototype and descriptor statics, wherever the member is read
requireDirectObjectUse: true the global Object may only be used directly: as Object.name with a name written in the source, called, constructed, or as the operand of typeof / instanceof. An alias (const O = Object), passing or storing it, destructuring from it, a member name computed at run time and Object.valueOf() are refused with OBJECT_INDIRECT_USE. The AgentScript preset switches this on.
ReservedPrefixRule
Prevents user code from declaring identifiers with reserved prefixes.const __ag_hack = 1;let __safe_bypass = true;__maxIterations, the runtime’s name for the iteration limit, whatever prefixes are configured
reservedPrefixes is the complete list. The reservedPrefixes option of the AgentScript preset adds to __ag_ and __safe_ instead.
NoCallTargetAssignmentRule
Protects critical call targets from being reassigned or shadowed.callTool = malicious;- Direct assignmentconst callTool = () => {};- Variable shadowingconst { callTool } = obj;- Destructuring shadowingfunction callTool() {}- Function declaration shadowing
++ / --, catch-clause patterns, parameters and their default values, and class names.
UnicodeSecurityRule
Reports bidirectional control characters, look-alike characters, zero-width characters and invisible characters in a script. The tag characters (U+E0000 to U+E007F) count as invisible characters. No preset includes this rule; add it to a validator yourself.StaticCallTargetRule
Enforces static string literals for call targets.callTool(dynamicName, {})- Variable as tool namecallTool(getToolName(), {})- Function call as tool name
callTool('users:list', {})- Static string literal
requireDirectCall: true (as in the AgentScript preset) nothing else may be done with the target function: no alias, no .call / .apply / .bind, no tagged template, no passing it as a value.
NoRegexLiteralRule
Blocks or analyzes regex literals for ReDoS vulnerabilities.DisallowedIdentifierRule
Blocks specific identifier names.ForbiddenLoopRule
Restricts which loop constructs are allowed.RequiredFunctionCallRule
Ensures code contains required function calls.UnknownGlobalRule
Rejects references to undeclared identifiers (whitelist mode).UNKNOWN_GLOBAL issue of a validation states the list of allowed globals (in its message and in data.allowedGlobals); the following ones name the identifier only.
NoEvalRule
Blocks eval and dynamic code execution.eval('code')new Function('return 1')setTimeout('code', 100)- String form
NoAsyncRule
Restricts async/await usage.NoUserDefinedFunctionsRule
Blocks user-defined functions (prevents recursion).allowedFunctionNames allows one declaration: the first one at the top level that has the shape of the wrapper (async function name() { ... }: async, not a generator, no parameters). Every other function declaration is refused whatever its name.
Blocks:
function foo() {}const fn = function() {}
array.map(x => x * 2)- Arrow functions (if enabled)
UnreachableCodeRule
Detects code after return/throw statements.CallArgumentValidationRule
Validates function call arguments.AllowedSyntaxRule
An allowlist of syntax: a script may only contain the listed ESTree node types.DISALLOWED_SYNTAX) unless listed under their own name: UsingDeclaration, AwaitUsingDeclaration, ForAwaitStatement and GeneratorFunction. Listing ForOfStatement allows for…of, not for await…of.
NoRegexMethodsRule
Blocks the string and regex methods that run a regular expression.match, matchAll and search compile a string argument into a regular expression, so with allowStringArguments: false they are refused with any argument. The method name is resolved in every static spelling (x.match, x['match'], a template literal without substitutions), and the call is seen through call / apply / bind, as a template tag and without an argument.
With requireDirectCall: true, a property named match, matchAll or search can only be called where it stands: reading it, passing or storing it and taking it by destructuring are refused. That also refuses reading a field of ordinary data with such a name (params.search), which is why it is off by default.
NoJsonCallbacksRule
BlocksJSON.stringify with a replacer function and JSON.parse with a reviver function.
requireDirectUse: true an alias of JSON, .call / .apply / .bind, a computed method name and every method other than parse and stringify are refused (JSON_INDIRECT_USE). Only the global undefined counts as “no replacer or reviver”, not a variable of the script with that name.
Rule Severity
A rule has a default severity. Override it per validation, by rule name:Related
- Custom Rules - Writing your own rules
- AgentScript Preset - Pre-configured ruleset
- Pre-Scanner - Layer 0 defense