mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 00:19:03 +02:00
fix(pairing): reject reserved clientId 'root' at all token writers
'root' is the sentinel checkScope/checkDomain/checkRate and the server command gate use for the omnipotent caller, so a scoped token carrying it bypasses every enforcement path. Add ReservedClientIdError + a shared assertValidClientId; createToken/createSetupKey throw, restoreRegistry skips-and-logs (a corrupt state file must not brick boot). /pair and /token surface it as a named 400, and the CLI fast-fails --client root. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
51932eceef
commit
783504d7ea
@@ -1225,6 +1225,14 @@ async function tunnelAgents(): Promise<number> {
|
||||
* opposite of the user's intent. And `control` never rides in via --restrict:
|
||||
* browser-wide destructive ops stay behind the explicit --control flag. */
|
||||
function validatePairAgentFlags(args: string[]): void {
|
||||
// `root` is the sentinel that bypasses all scope/domain/rate/tab enforcement;
|
||||
// naming an agent that way would silently un-sandbox it. Reject client-side
|
||||
// before hitting the daemon (the server rejects it too).
|
||||
const client = parseFlag(args, '--client');
|
||||
if (client !== undefined && client.trim().toLowerCase() === 'root') {
|
||||
console.error("[browse] --client 'root' is reserved — it would bypass all scope enforcement. Choose another name.");
|
||||
process.exit(1);
|
||||
}
|
||||
// hasFlag/parseFlag are exact-token matches, so `--restrict=read` would
|
||||
// sail past every check below and silently grant FULL access.
|
||||
if (args.some(a => a.startsWith('--restrict='))) {
|
||||
|
||||
Reference in New Issue
Block a user