惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
罗磊的独立博客
The GitHub Blog
The GitHub Blog
L
LangChain Blog
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net
宝玉的分享
宝玉的分享
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
N
Netflix TechBlog - Medium
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
美团技术团队
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(auth): prevent bootstrap pairing scope changes [AI] (...
pgondhi987 · 2026-05-12 · via Recent Commits to openclaw:main

@@ -23,6 +23,7 @@ export type DeviceBootstrapTokenRecord = {

2323

publicKey?: string;

2424

profile?: DeviceBootstrapProfile;

2525

redeemedProfile?: DeviceBootstrapProfile;

26+

pendingProfile?: DeviceBootstrapProfile;

2627

roles?: string[];

2728

scopes?: string[];

2829

issuedAtMs: number;

@@ -67,6 +68,35 @@ function resolvePersistedRedeemedProfile(

6768

return normalizeDeviceBootstrapProfile(record.redeemedProfile);

6869

}

697071+

function resolvePersistedPendingProfile(

72+

record: Partial<DeviceBootstrapTokenRecord>,

73+

): DeviceBootstrapProfile | null {

74+

return record.pendingProfile ? normalizeDeviceBootstrapProfile(record.pendingProfile) : null;

75+

}

76+77+

function resolveRequestedBootstrapProfile(params: {

78+

role: string;

79+

scopes: readonly string[];

80+

}): DeviceBootstrapProfile {

81+

return normalizeDeviceBootstrapProfile({

82+

roles: [params.role],

83+

scopes: resolveBootstrapProfileScopesForRole(params.role, params.scopes),

84+

});

85+

}

86+87+

function sameBootstrapProfile(

88+

left: DeviceBootstrapProfile,

89+

right: DeviceBootstrapProfile,

90+

): boolean {

91+

if (left.roles.length !== right.roles.length || left.scopes.length !== right.scopes.length) {

92+

return false;

93+

}

94+

return (

95+

left.roles.every((role, index) => role === right.roles[index]) &&

96+

left.scopes.every((scope, index) => scope === right.scopes[index])

97+

);

98+

}

99+70100

function resolveIssuedBootstrapProfile(params: {

71101

profile?: DeviceBootstrapProfileInput;

72102

roles?: readonly string[];

@@ -173,10 +203,12 @@ async function loadState(baseDir?: string): Promise<DeviceBootstrapStateFile> {

173203

typeof record.token === "string" && record.token.trim().length > 0 ? record.token : tokenKey;

174204

const issuedAtMs = typeof record.issuedAtMs === "number" ? record.issuedAtMs : 0;

175205

const profile = resolvePersistedBootstrapProfile(record);

206+

const pendingProfile = resolvePersistedPendingProfile(record);

176207

state[tokenKey] = {

177208

token,

178209

profile,

179210

redeemedProfile: resolvePersistedRedeemedProfile(record),

211+

...(pendingProfile ? { pendingProfile } : {}),

180212

deviceId: typeof record.deviceId === "string" ? record.deviceId : undefined,

181213

publicKey: typeof record.publicKey === "string" ? record.publicKey : undefined,

182214

issuedAtMs,

@@ -304,18 +336,33 @@ export async function redeemDeviceBootstrapTokenProfile(params: {

304336

}

305337

const [tokenKey, record] = found;

306338

const issuedProfile = resolvePersistedBootstrapProfile(record);

339+

const pendingProfile = resolvePersistedPendingProfile(record);

307340

const redeemedProfile = normalizeDeviceBootstrapProfile({

308341

roles: [...resolvePersistedRedeemedProfile(record).roles, params.role],

309342

scopes: [

310343

...resolvePersistedRedeemedProfile(record).scopes,

311344

...resolveBootstrapProfileScopesForRole(params.role, params.scopes),

312345

],

313346

});

314-

state[tokenKey] = {

347+

const nextPendingProfile =

348+

pendingProfile &&

349+

!bootstrapProfileSatisfiesProfile({

350+

actualProfile: redeemedProfile,

351+

requiredProfile: pendingProfile,

352+

})

353+

? pendingProfile

354+

: undefined;

355+

const nextRecord: DeviceBootstrapTokenRecord = {

315356

...record,

316357

profile: issuedProfile,

317358

redeemedProfile,

318359

};

360+

if (nextPendingProfile) {

361+

nextRecord.pendingProfile = nextPendingProfile;

362+

} else {

363+

delete nextRecord.pendingProfile;

364+

}

365+

state[tokenKey] = nextRecord;

319366

await persistState(state, params.baseDir);

320367

return {

321368

recorded: true,

@@ -368,6 +415,10 @@ export async function verifyDeviceBootstrapToken(params: {

368415

) {

369416

return { ok: false, reason: "bootstrap_token_invalid" };

370417

}

418+

const requestedProfile = resolveRequestedBootstrapProfile({

419+

role,

420+

scopes: params.scopes,

421+

});

371422372423

const boundDeviceId = record.deviceId?.trim();

373424

const boundPublicKey =

@@ -378,9 +429,14 @@ export async function verifyDeviceBootstrapToken(params: {

378429

if (boundDeviceId !== deviceId || boundPublicKey !== publicKey) {

379430

return { ok: false, reason: "bootstrap_token_invalid" };

380431

}

432+

const pendingProfile = resolvePersistedPendingProfile(record);

433+

if (pendingProfile && !sameBootstrapProfile(pendingProfile, requestedProfile)) {

434+

return { ok: false, reason: "bootstrap_token_invalid" };

435+

}

381436

state[tokenKey] = {

382437

...record,

383438

profile: allowedProfile,

439+

pendingProfile: pendingProfile ?? requestedProfile,

384440

deviceId,

385441

publicKey,

386442

lastUsedAtMs: Date.now(),

@@ -392,6 +448,7 @@ export async function verifyDeviceBootstrapToken(params: {

392448

state[tokenKey] = {

393449

...record,

394450

profile: allowedProfile,

451+

pendingProfile: requestedProfile,

395452

deviceId,

396453

publicKey,

397454

lastUsedAtMs: Date.now(),