The safest response is to terminate the subprocess group, stop collecting further output, and let the CI job end in an aborted state. That prevents orphaned child processes and avoids false confidence from a partially completed scan. A controlled shutdown also preserves the diagnostic output gathered before failure, which is usually the most useful evidence for troubleshooting.
What should happen when the scan cannot recover?
When a Jenkins-driven interactive test hits an error condition it cannot clear, the right outcome is to fail closed: terminate the subprocess group, stop reading output, and end the job as aborted rather than pretending the test completed. That keeps the CI result honest, prevents stuck children from consuming resources, and preserves the evidence already collected.
That behaviour matters most when the job drives external tools or scripts that can keep running after the parent shell has failed. In CI, a partially healthy process tree is often more dangerous than a clean failure because it can leave behind orphaned activity, locked files, open ports, or misleading logs that suggest progress continued.
Jenkins itself does not make an unrecoverable test safe by default. The test harness has to define the failure boundary clearly, treat the error as terminal, and make sure cleanup happens even if the main command exits unexpectedly. In practice, that means the control flow should favour controlled abort over retry loops that only mask the underlying fault.
Why termination is safer than trying to limp on
The main risk in an unrecoverable interactive test is state corruption. Once the tool has lost a valid execution path, continuing to collect output can produce a result set that looks complete but is no longer trustworthy. That false confidence is especially harmful in automated pipelines because downstream stages may assume the scan passed, or may act on partial data as if it were authoritative.
Another failure mode is process leakage. A parent Jenkins step can fail while child processes, background workers, or spawned shells continue to run. If they are not terminated together, they can hold resources, interfere with later builds, or keep probing systems long after the operator thought the job was over.
Controlled shutdown preserves the most useful artefact, which is the output gathered before the failure point. That evidence often tells you whether the issue was a tool crash, a target-side timeout, an authentication problem, or a harness bug. Once the subprocess tree is torn down cleanly, the remaining investigation can focus on the cause instead of trying to disentangle an unstable execution state.
How to treat the failure as an operational signal
An unrecoverable error should be treated as a meaningful signal from the test environment, not as a temporary inconvenience to suppress. If the scan cannot recover, the operator should assume the current run has lost diagnostic value beyond the failure boundary and should not let the pipeline continue on the strength of a degraded result.
That is why the best outcome is an aborted CI job with a clear exit state, not a nominally successful job with warnings buried in the console. The aborted status tells both humans and automation that the run did not reach a trustworthy conclusion and that any downstream decision must wait for a clean rerun or manual review.
Where a Jenkins pipeline wraps interactive tools, the harness should also make the shutdown path deterministic. If the cleanup logic depends on the same failing process to stay alive long enough to run, it is too fragile. A separate teardown path, or an outer timeout and kill strategy, is usually more reliable than trying to recover inside the dead process itself.
Risk and Threat Considerations
An unrecoverable interactive test can create both reliability risk and security exposure if the failed job keeps running in the background. Orphaned children may continue using credentials, touching targets, or holding connections open after the parent build has already lost control of the session.
Failure mechanism: the main Jenkins step exits or hangs while spawned subprocesses remain active, so the pipeline no longer has a single authoritative view of execution state.
Impact: you can get resource leakage, stale or misleading test output, and a larger blast radius if the leftover process continues interacting with systems that were supposed to be under controlled test conditions.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | RC.RP-01 — Response Plan Execution | Interactive test aborts need a controlled recovery and shutdown path. |
| RS.MA-1 — Response Plan Execution | The job needs a defined action when the scan cannot recover. | |
| Recommendation — Execute the response plan to terminate the run cleanly and preserve evidence. Carry out the planned shutdown steps and stop further execution. | ||
| NIST SP 800-53 Rev 5 | AU-2 — Audit Events | The run must retain useful diagnostic evidence from the failure point. |
| CP-10 — System Recovery and Reconstitution | Abort handling should restore the pipeline to a clean state after failure. | |
| Recommendation — Record the failure event and preserve the logs needed for troubleshooting. Restore the environment to a known good state before rerunning the job. | ||
| CIS Controls v8 | CIS-8 — Audit Log Management | Preserving the failure trail is central to diagnosing the aborted test. |
| Recommendation — Retain the logs and failure output needed to investigate the aborted run. | ||
| ISO/IEC 27001:2022 | A.8.13 — Information backup | Controlled shutdown protects collected evidence and supports recovery after failure. |
| Recommendation — Preserve the evidence needed to recover and rerun the failed test safely. | ||
Practitioner Guidance
What to verify: Confirm that the job kills the whole process group, not just the top-level shell. If the tool can fork, detach, or spawn helpers, the cleanup step needs to catch all of them or the build is not truly terminated.
Decision rule: If the test can no longer produce a trustworthy result, stop collecting output and abort the job rather than trying to preserve a “best effort” pass. Only keep the run alive if the harness can still enforce bounded, observable recovery without losing process control.
What good looks like: the console log clearly shows the failure point, the subprocess tree is gone, and the final build state tells operators that the scan ended incompletely. That gives you a clean rerun path and avoids treating a partial execution as evidence of success.
Practitioner takeaway: In CI, the safest failure is the one that ends decisively, cleans up completely, and leaves behind enough evidence to diagnose the root cause without continuing an untrusted run.
Related resources from NHI Mgmt Group
- What happens when mobile security teams cannot test across multiple iOS versions with root access?
- What happens when an allowlisting test can write files but cannot delete them afterward?
- What happens when ticketing merchants cannot distinguish scam-driven purchases from genuine demand?
- What happens if organisations cannot recover Active Directory granularly after an incident?