From 7e638ec8a1ae99e7661287f42f6463ff9e57788c Mon Sep 17 00:00:00 2001 From: "Archimedes (Paperclip)" Date: Wed, 25 Nov 2026 21:10:49 +0000 Subject: [PATCH] =?UTF-8?q?fix(git):=20::/96=20in=20SSRF-BlockList,=20URL-?= =?UTF-8?q?Tests=20f=C3=BCr=20IPv6-Literale,=20ESLint=20no-nested-ternary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-Review PR #19: IPv4-kompatible Adressen (::7f00:1) fehlten in der BlockList, CI scheiterte an einem verschachtelten Ternary in editorPage.jsx. Co-Authored-By: Claude Opus 5.5 --- client/homebrew/pages/basePages/editPage/editorPage.jsx | 3 ++- server/fork/git/git.unit.spec.js | 6 +++++- server/fork/git/urlPolicy.js | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/homebrew/pages/basePages/editPage/editorPage.jsx b/client/homebrew/pages/basePages/editPage/editorPage.jsx index d0322f03..4b644d46 100644 --- a/client/homebrew/pages/basePages/editPage/editorPage.jsx +++ b/client/homebrew/pages/basePages/editPage/editorPage.jsx @@ -214,7 +214,8 @@ const EditorPage = (props)=>{ clearTimeout(saveTimeout.current); if(isSaving) return; if(!forceSave && !hasChanges) return; - const newTimeout = forceSave ? 0 : (gitLinked ? GIT_SAVE_TIMEOUT : SAVE_TIMEOUT); + const autoSaveTimeout = gitLinked ? GIT_SAVE_TIMEOUT : SAVE_TIMEOUT; // [fork] ADR-0003 F6 + const newTimeout = forceSave ? 0 : autoSaveTimeout; saveTimeout.current = setTimeout(async ()=>{ setIsSaving(true); diff --git a/server/fork/git/git.unit.spec.js b/server/fork/git/git.unit.spec.js index 77c82611..c95c44e7 100644 --- a/server/fork/git/git.unit.spec.js +++ b/server/fork/git/git.unit.spec.js @@ -81,7 +81,7 @@ describe('URL-Policy (SSRF)', ()=>{ await expect(assertUrlAllowed('https://git.example.test:8443/a/b.git', cfg, { lookup: pub })).resolves.toBeDefined(); }); - test.each(['127.0.0.1', '10.1.2.3', '172.16.0.1', '172.31.255.255', '192.168.1.1', '169.254.169.254', '100.64.0.1', '0.0.0.0', '::1', 'fd00::1', 'fe80::1', '::ffff:127.0.0.1', '::ffff:7f00:1', '::ffff:a9fe:a9fe', '::ffff:10.0.0.1', '0:0:0:0:0:ffff:7f00:1', '64:ff9b::7f00:1', '224.0.0.1'])('%s gilt als intern', (ip)=>{ + test.each(['127.0.0.1', '10.1.2.3', '172.16.0.1', '172.31.255.255', '192.168.1.1', '169.254.169.254', '100.64.0.1', '0.0.0.0', '::1', 'fd00::1', 'fe80::1', '::ffff:127.0.0.1', '::ffff:7f00:1', '::ffff:a9fe:a9fe', '::ffff:10.0.0.1', '0:0:0:0:0:ffff:7f00:1', '64:ff9b::7f00:1', '::7f00:1', '::a9fe:a9fe', '224.0.0.1'])('%s gilt als intern', (ip)=>{ expect(isPrivateAddress(ip)).toBe(true); }); test.each(['8.8.8.8', '93.184.216.34', '172.32.0.1', '2606:4700::1111'])('%s gilt als öffentlich', (ip)=>{ @@ -95,6 +95,10 @@ describe('URL-Policy (SSRF)', ()=>{ await expect(assertUrlAllowed('https://[::1]/a/b', cfg, { lookup: pub })).rejects.toThrow(); }); + test.each(['[::ffff:127.0.0.1]', '[::ffff:a9fe:a9fe]', '[::ffff:10.0.0.1]', '[64:ff9b::7f00:1]', '[::7f00:1]'])('IPv6-Literal %s in der URL wird abgelehnt', async (host)=>{ + await expect(assertUrlAllowed(`https://${host}/a/b.git`, cfg, { lookup: pub })).rejects.toMatchObject({ HBErrorCode: 'G08' }); + }); + test('HB_GIT_ALLOW_PRIVATE erlaubt interne Ziele, HB_GIT_ALLOW_HTTP http://', async ()=>{ await expect(assertUrlAllowed('http://127.0.0.1:3000/a/b', { ...cfg, allowPrivate: true, allowHttp: true })).resolves.toBeDefined(); expect(()=>parseRepoUrl('http://x.test/a/b', { allowHttp: true })).not.toThrow(); diff --git a/server/fork/git/urlPolicy.js b/server/fork/git/urlPolicy.js index 659ffeaa..1f3de1c8 100644 --- a/server/fork/git/urlPolicy.js +++ b/server/fork/git/urlPolicy.js @@ -24,11 +24,12 @@ const blocked = new net.BlockList(); ['172.16.0.0', 12], ['192.0.0.0', 24], ['192.168.0.0', 16], ['198.18.0.0', 15], ['224.0.0.0', 3] ].forEach(([n, p])=>blocked.addSubnet(n, p, 'ipv4')); [ - ['::', 128], ['::1', 128], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8], - // IPv4-gemappte Adressen (::ffff:a.b.c.d / ::ffff:a9fe:a9fe) prüft BlockList selbst gegen die IPv4-Regeln + ['::', 96], // IPv4-kompatibel (::a.b.c.d), schließt :: und ::1 ein + ['::1', 128], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8], ['64:ff9b::', 96], // NAT64 ['2002::', 16] // 6to4 ].forEach(([n, p])=>blocked.addSubnet(n, p, 'ipv6')); +// IPv4-gemappte Adressen (::ffff:a.b.c.d, auch als ::ffff:7f00:1) prüft BlockList selbst gegen die IPv4-Regeln. export const isPrivateAddress = (address)=>{ const ip = String(address).toLowerCase().replace(/^\[|\]$/g, '').split('%')[0];