T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/safari_control.swift:3149- Finding
Unrestricted Export of Script-Readable Safari Session Data
- Content
View full analysis
{ const cookies = document.cookie .split(';') .map((item) => item.trim()) .filter(Boolean) .map((item) => { const idx = item.indexOf('='); if (idx === -1) return { name: item, value: '' }; return { name: item.slice(0, idx), value: item.slice(idx + 1) }; }); return JSON.stringify(cookies); })() """# let cookies = parseJSON( try jsResult(code, target: try options.tabTarget()), default: [] ) as? [[String: Any]] ?? [] if let path = options.string("--path") { let url = try writeJSONOutput(path: path, value: cookies) try printJSON([ "ok": true, "path": url.path, "count": cookies.count, "kind": "cookies" ]) } else { try printJSON(cookies) } } func cmdExportStorage(_ options: CommandOptions) throws { guard let kind = options.positionals.first else { throw SafariControlError(message: "export-storage requires local or session.") } let storageExpr = kind == "local" ? "localStorage" : "sessionStorage" let code = #""" (() => { const out = {}; for (let i = 0; i < \#(storageExpr).length; i++) { const key = \#(storageExpr).key(i); out[key] = \#(storageExpr).getItem(key); } return JSON.stringify(out); })() """# let storage = parseJSON( try jsResult(code, target: try options.tabTarget()), default: [:] ) as? [String: Any] ?? [:] if let path = options.string("--path") { let url = try writeJSONOutput(path: path, value: storage) try printJSO ...[truncated 3285 chars]- Remediation
View remediation
