fix(inbound,security): bound the sync prefix of inbound scripts by the method timeout; persist a role refresh done on a passive request (INB-1, SEC-1, WP7 task 7.6)

This commit is contained in:
Joseph Doherty
2026-12-03 09:49:51 -05:00
parent 76c50a29c2
commit f7d3c69071
6 changed files with 84 additions and 7 deletions
@@ -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