Follow-up from #1967 (attachment object-store pipeline).
scripts/backfill-images.ts:68 gates the GitHub Bearer-token fallback on an UNANCHORED substring regex: /raw\.githubusercontent\.com/.test(u). A lookalike host such as https://raw.githubusercontent.com.evil.com/x (or https://evil.com/?q=raw.githubusercontent.com) matches, so the GitHub token could be sent to an attacker-controlled host (credential exfiltration). Low exploitability in practice (the collected URLs originate from sap-tutorials-org tutorial HTML), but the pattern is wrong.
The attachment sibling scripts/backfill-attachments.ts already fixed this in #1967 with an exact-hostname helper:
export function isRawGithubHost(u: string): boolean {
try { return new URL(u).hostname.toLowerCase() === 'raw.githubusercontent.com'; } catch { return false; }
}
Port isRawGithubHost into backfill-images.ts (or share it), replace the substring test at line 68, and add the same unit tests (true for the legit host; false for subdomain lookalike, query-param embed, malformed URL).
Follow-up from #1967 (attachment object-store pipeline).
scripts/backfill-images.ts:68gates the GitHub Bearer-token fallback on an UNANCHORED substring regex:/raw\.githubusercontent\.com/.test(u). A lookalike host such ashttps://raw.githubusercontent.com.evil.com/x(orhttps://evil.com/?q=raw.githubusercontent.com) matches, so the GitHub token could be sent to an attacker-controlled host (credential exfiltration). Low exploitability in practice (the collected URLs originate from sap-tutorials-org tutorial HTML), but the pattern is wrong.The attachment sibling
scripts/backfill-attachments.tsalready fixed this in #1967 with an exact-hostname helper:Port
isRawGithubHostintobackfill-images.ts(or share it), replace the substring test at line 68, and add the same unit tests (true for the legit host; false for subdomain lookalike, query-param embed, malformed URL).