Files
wekan/tests/apacheReverseProxy.test.cjs
T
Lauri Ojansivu 577ccb9f83 Keep Apache reverse-proxy examples closed
Set ProxyRequests Off explicitly in both documented WeKan virtual hosts so an unsafe inherited global setting cannot expose an open forward proxy. Remove the obsolete wildcard proxy authorization and explain why ProxyMaxForwards does not address the vulnerability. Add positive and negative configuration regressions.

Thanks to bastos77 and xet7 !

Fixes #3001,
2026-08-25 19:00:43 +03:00

40 lines
1.2 KiB
JavaScript

'use strict';
// Regression coverage for #3001. The documented Apache configuration must be
// a reverse proxy only, never an Internet-facing forward proxy.
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const source = fs.readFileSync(
path.join(__dirname, '..', 'docs/Platforms/Webserver/Apache.md'),
'utf8',
);
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
test('every example virtual host explicitly disables forward proxying', () => {
const virtualHosts = [...source.matchAll(/<VirtualHost[^>]*>([\s\S]*?)<\/VirtualHost>/g)];
assert.strictEqual(virtualHosts.length, 2);
for (const [, body] of virtualHosts) {
assert.match(body, /^\s*ProxyRequests Off\s*$/m);
}
});
test('the guide never enables or grants wildcard access to a forward proxy', () => {
assert.doesNotMatch(source, /^\s*ProxyRequests On\s*$/m);
assert.doesNotMatch(source, /<Proxy\s+["']?\*["']?>/i);
});
test('the ineffective forwarding-depth workaround is rejected', () => {
assert.match(source, /`ProxyMaxForwards`[^\n]+does\s+not close an open proxy/);
});
console.log(`\napacheReverseProxy: ${passed} tests passed`);