Log date · Mon
How do you test defenses against dynamic analysis?
Published on · Updated
Static search is not enough: two computed values missed in our file search were visible to the Node inspector at runtime.
The short answer: test the running process
No. In two runs of our Node.js sample, an exact search of the program file found neither complete result, yet the Node inspector read both after computation. Inputs 37 and 91 produced DEMO-1037-2091; inputs 53 and 22 produced DEMO-1053-2022.
Static and runtime checks answer different questions. One examines what is in a delivered file; the other examines what can be observed at a particular point during execution. A defense assessment needs both, under explicitly stated conditions.
| Question | Result |
|---|---|
| Were the two complete values in the program file? | Neither matched an exact search. |
| Could the runtime reveal them? | The inspector returned both. |
| Does this prove a defense was bypassed? | No: the sample deliberately opens a same-process session. |
The sample and test conditions
We ran a CommonJS file we wrote ourselves on macOS with Node.js 20.19.5. It takes two numbers from the command line, adds 1000 and 2000 respectively, and assembles a fictional quote marker. It is not a credential. The file itself is the artifact in this test; there is no separate compilation step.
The sample puts the result on globalThis, then deliberately connects a same-process inspector session and reads it. We compare two inputs; we did not test external debugger attachment, breakpoints, commercial protection or another app. The result describes this controlled setup. Node documents that Session connects to the inspector backend and post sends a message whose response arrives in a callback. [1]
'use strict';
const inspector = require('node:inspector');
const session = new inspector.Session();
session.connect();
globalThis.quote = `DEMO-${1000 + Number(process.argv[2])}-${2000 + Number(process.argv[3])}`;
session.post('Runtime.evaluate', { expression: 'globalThis.quote' }, (error, response) => {
if (error) throw error;
console.log('inspector:', response.result.value);
session.disconnect();
});Search the file, then inspect the runtime
The script calculates the expected markers from the inputs and uses grep to search sample.cjs for each complete byte string. Both searches miss; the sample then runs twice, and each inspector response matches its input. The record below includes the version and output from the same run.
== version ==
v20.19.5
== exact static search of sample.cjs ==
DEMO-1037-2091 | absent
DEMO-1053-2022 | absent
== inspector, input 37 91 ==
inspector: DEMO-1037-2091
== inspector, input 53 22 ==
inspector: DEMO-1053-2022The search covers one program file and matches only the complete literal. A miss does not mean that the file hides the calculation: the source shows the prefix, offsets and assembly directly. Someone who knows the rule can calculate the result too. The point is the difference between searching for a complete result and reading a result that has already been computed.
The callback prints response.result.value. We deliberately place the value on the global object so the expression can find it, and the sample creates the session itself. That makes this a useful observation exercise, not a score for a protection product or evidence that a release build without debugging support has the same access path.
Design a useful defense assessment
Start by naming what matters: a pricing rule, an authorization result, or a server token, for example. Record whether the evaluator controls the device, can start a debug build, and can see inputs and outputs. Different results under different access conditions are not contradictory.
Prepare ordinary, boundary and failure inputs for each critical flow and keep an unprotected baseline. Compare versions with the same data and environment; record whether the value was observed, the permissions, steps, actual errors and any functional or performance change. Record where an attempt failed: one failure does not establish that every runtime observation will fail.
| Case | Recommendation |
|---|---|
| Inspecting delivered files | Search for known test markers and review resources, maps and dependencies. |
| Inspecting a runtime flow | Observe key steps in an authorized test environment; record access and inputs. |
| Comparing defense versions | Hold sample and conditions constant; retain baseline and failure logs. |
| A shared privileged secret | Keep it on a controlled server, restrict privileges and rotate it. |
These are assessment recommendations, not product conclusions measured by the two runs. In particular, distinguish a value missing from one search from a value being impossible to observe. Likewise, detecting one debugging condition establishes behavior under that condition, not against every tool and device.
Run a check on your own app
Save the sample above as sample.cjs, then run the commands below. For your own test build, use the same idea with a non-sensitive marker and record the result in an authorized environment. The search returns a nonzero status when it finds nothing, so the conditional reports either outcome explicitly.
if grep -aqF 'DEMO-1037-2091' sample.cjs; then echo present; else echo absent; fi
node sample.cjs 37 91
node sample.cjs 53 22A real application may not place a value in a global variable or allow test code to be added. Choose an observable step in a development build and record how it differs from the release build; do not treat a test debugging interface as a production interface. Node also provides --inspect-brk to pause at the start of the user script for a debugging client. [3]
Debugger access is powerful. Node warns that someone able to connect to the debugging port may execute code as the process; do not expose it publicly or use real user data in this exercise. [2] Close the session after testing and check that logs and reports contain only placeholder data.
Finally, give reviewers the evidence: retain the sample, commands, tool versions and raw output, with expected and actual results. Mark any step that was not run as unexecuted. If a result depends on test code or a debug build, put that condition beside the finding. This makes the comparison repeatable after the next release change.
Interpret the comparison
Write findings as separate observations. For example, record the exact artifact and encoding searched, the point in execution, the build and the privileges used for runtime inspection. When the artifact changes, first verify that it still passes the same functional test before comparing visibility. Otherwise an absent value may simply mean the flow never reached the point of interest.
Classify each result as observed, not observed, or not executed. A not-observed result needs its method and any error; an unexecuted step cannot count as a pass. For a repeat, the reviewer should have the same sample, inputs and version, see the original record, and know which steps depend on a special test build. That turns a demonstration into traceable engineering evidence.
An assessment should also check effects on ordinary users: whether the same input produces the same result, whether error paths remain recoverable, and whether startup and critical flows incur acceptable delay. Report function, performance and observability separately so the team can decide whether a change is worthwhile.
Your checklist
- Define the asset, device control and debugging access.
- Keep a baseline and fix inputs, versions and environment.
- Inspect release files, then test critical runtime flows.
- Record actual output, failures and test-build differences.
- Use placeholder data and close the test debugging session.
Primary sources
- Node.js Inspector API · Checked 2026-11-11
- Node.js: Debugging · Checked 2026-11-11
- Node.js 20 Command-line API · Checked 2026-11-11