diff --git a/docs/requirements/Component-InboundAPI.md b/docs/requirements/Component-InboundAPI.md
index 5585bd03..a8f76882 100644
--- a/docs/requirements/Component-InboundAPI.md
+++ b/docs/requirements/Component-InboundAPI.md
@@ -69,7 +69,7 @@ Each API method definition includes:
- **Return Value Definition**: Structure of the response, with:
- Field names and (extended-system) data types. Supports returning **lists of objects** and arbitrarily nested structures.
- **Implementation Script**: C# script that executes when the method is called. Stored **inline** in the method definition. Follows standard C# authoring patterns but has no template inheritance — it is a standalone script tied to this method.
-- **Timeout**: Configurable per method. Defines the maximum time the method is allowed to execute (including any routed calls to sites) before returning a timeout error to the caller.
+- **Timeout**: Configurable per method. Defines the maximum time the method is allowed to execute (including any routed calls to sites) before returning a timeout error to the caller. The script is started on the thread pool (not inline on the request thread), so the timeout also bounds the synchronous prefix of the script — CPU work or a blocking call before its first `await` — and a script that overruns is abandoned and counted exactly like one that blocks later (review INB-1).
- **TraceAllCalls** (Flow Debugger, 2026-09-05): when set, every call to this method runs its routed site scripts with the trace flag on, so their `ScriptRun` / `AttributeWrite` / `AttributeWait` audit rows (`AuditChannel.ScriptTrace`) are recorded for Replay. Default off — adds 7–10 audit rows per call (3 of them trace-only; a cached DB write and a notification account for the upper end), so it is meant for low-volume integration methods. Set from the method form's *Trace all calls* checkbox or `api-method create|update --trace-all-calls`.
> **Authoring note — idempotent methods for at-least-once callers**: some external callers retry
diff --git a/docs/requirements/Component-Security.md b/docs/requirements/Component-Security.md
index 7e9270a6..da4336c7 100644
--- a/docs/requirements/Component-Security.md
+++ b/docs/requirements/Component-Security.md
@@ -234,4 +234,4 @@ To blunt online password-spray and brute-force against the directory, every LDAP
### Passive traffic and circuit refresh (2026-09-09)
-`/auth/ping`, `/auth/activity`, and Blazor transport validation do not advance inactivity timestamps or trigger sliding renewal. The explicit activity endpoint validates antiforgery before renewing the cookie and recording activity by protected session ID. A bounded process-local tracker lets a live circuit observe successful activity renewal. Role refresh preserves the session ID and activity timestamp; current circuit mutation checks re-map stored groups with fail-closed lookup behavior. Display-only auth-state reads reuse the circuit's last revalidation for up to 10 s (review 2026-10-21 07/P-3), so an idle timeout or a revoked grant can show on a read-only surface for at most that long; it never reaches a mutation.
+`/auth/ping`, `/auth/activity`, and Blazor transport validation do not advance inactivity timestamps or trigger sliding renewal. The explicit activity endpoint validates antiforgery before renewing the cookie and recording activity by protected session ID. A bounded process-local tracker lets a live circuit observe successful activity renewal. Role refresh preserves the session ID and activity timestamp, and its rebuilt ticket is persisted even when the refresh happened on a passive request (the refresh anchors advance, so the next ping does not repeat the role re-map / directory query; the ticket still carries the OLD activity timestamp, so persisting it never extends the idle window); current circuit mutation checks re-map stored groups with fail-closed lookup behavior. Display-only auth-state reads reuse the circuit's last revalidation for up to 10 s (review 2026-10-21 07/P-3), so an idle timeout or a revoked grant can show on a read-only surface for at most that long; it never reaches a mutation.
diff --git a/src/ZB.MOM.WW.ScadaBridge.InboundAPI/InboundScriptExecutor.cs b/src/ZB.MOM.WW.ScadaBridge.InboundAPI/InboundScriptExecutor.cs
index 17a2e45a..80c26de8 100644
--- a/src/ZB.MOM.WW.ScadaBridge.InboundAPI/InboundScriptExecutor.cs
+++ b/src/ZB.MOM.WW.ScadaBridge.InboundAPI/InboundScriptExecutor.cs
@@ -625,7 +625,15 @@ public class InboundScriptExecutor
_scriptHandlers[method.Name] = cached; // last-write-wins; concurrent first-callers race benignly
}
- handlerTask = cached.Handler(context);
+ // Start the handler OFF the request thread (INB-1). Script.RunAsync runs the script
+ // synchronously up to its first incomplete await, so invoking the handler inline would
+ // hold the request thread with no deadline for any script that does CPU work or a
+ // blocking call before its first await (TimeoutSeconds and client disconnect both
+ // ignored, no TIMEOUT, abandoned-execution count stuck at 0). Running it on the pool
+ // lets WaitAsync bound the WHOLE run; a non-cooperative script is then abandoned and
+ // counted exactly like one that blocks after an await.
+ var handler = cached.Handler;
+ handlerTask = Task.Run(() => handler(context), cts.Token);
var result = await handlerTask.WaitAsync(cts.Token);
var resultJson = result != null
diff --git a/src/ZB.MOM.WW.ScadaBridge.Security/ServiceCollectionExtensions.cs b/src/ZB.MOM.WW.ScadaBridge.Security/ServiceCollectionExtensions.cs
index 3c2c87c6..367149bc 100644
--- a/src/ZB.MOM.WW.ScadaBridge.Security/ServiceCollectionExtensions.cs
+++ b/src/ZB.MOM.WW.ScadaBridge.Security/ServiceCollectionExtensions.cs
@@ -255,7 +255,7 @@ public static class ServiceCollectionExtensions
/// asks it for a decision, and applies it to the cookie context:
///
/// → + sign out (idle timeout, the directory reports the user gone/disabled/ambiguous/group-less — ScadaBridge#46, or the user's groups now map to no role — ScadaBridge#144).
- /// → + renewal only for non-passive requests (role mapping refreshed).
+ /// → + renewal so the refreshed ticket persists, passive requests included (role mapping refreshed).
/// → no-op (no refresh due, or a swallowed refresh fault).
///
/// All logic lives in , which never
@@ -302,9 +302,16 @@ public static class ServiceCollectionExtensions
case SessionValidationAction.Replace when result.Principal is not null:
// Role mapping refreshed from stored groups — swap in the rebuilt
- // principal and re-issue the cookie so the new claims persist.
+ // principal and re-issue the cookie so the new claims (and the advanced
+ // role/group refresh anchors) persist. This holds for passive requests too
+ // (SEC-1): without it the refreshed anchors were thrown away, the next ping
+ // arrived with the old ones and repeated the role re-map / LDAP re-query on every
+ // keep-alive. A passive request's rebuilt principal keeps the OLD LastActivity
+ // claim (CookieSessionValidator, recordActivity: false), so persisting it never
+ // extends the idle window; the sliding renewal of an UNCHANGED principal stays
+ // suppressed for passive requests (OnCheckSlidingExpiration above).
context.ReplacePrincipal(result.Principal);
- context.ShouldRenew = !IsPassiveSessionRequest(context.HttpContext);
+ context.ShouldRenew = true;
break;
case SessionValidationAction.Keep:
diff --git a/tests/ZB.MOM.WW.ScadaBridge.InboundAPI.Tests/InboundScriptExecutorTests.cs b/tests/ZB.MOM.WW.ScadaBridge.InboundAPI.Tests/InboundScriptExecutorTests.cs
index 0d8a701c..27d22c0f 100644
--- a/tests/ZB.MOM.WW.ScadaBridge.InboundAPI.Tests/InboundScriptExecutorTests.cs
+++ b/tests/ZB.MOM.WW.ScadaBridge.InboundAPI.Tests/InboundScriptExecutorTests.cs
@@ -1106,6 +1106,40 @@ public class InboundScriptExecutorTests
Assert.Equal(0, _executor.AbandonedExecutionCount); // ...and DECREMENTED
}
+ ///
+ /// INB-1: a script that blocks BEFORE its first await (CPU loop, .Result on a helper) used to
+ /// run inline on the request thread, so the method timeout could not fire until it returned. The
+ /// request must come back with TIMEOUT at the deadline and the orphan must be counted.
+ ///
+ /// A task that represents the asynchronous operation.
+ [Fact]
+ public async Task ScriptBlockingBeforeFirstAwait_StillTimesOutAtTheDeadline()
+ {
+ var release = new ManualResetEventSlim();
+ _executor.RegisterHandler("spin", _ =>
+ {
+ release.Wait(TimeSpan.FromSeconds(30)); // synchronous block: no await has happened yet
+ return Task.FromResult