mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 15:39:41 +02:00
feat(docker): allowlist container-to-host gateway aliases in host guard
An in-container hook curl carries Host: host.docker.internal:<port> (the derived CODEMAN_API_URL), so the always-on host guard must allow host.docker.internal / host.containers.internal or every in-container hook is blocked 403. Exact-match only; not a browser DNS-rebinding surface (resolves to the host only from inside a container netns). Verified end-to-end: quick-start launches claude/shell in a real container with the workspace bind-mounted and hooks scaffolded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,13 @@ describe('isAllowedRequestHost — anti-DNS-rebinding', () => {
|
||||
expect(isAllowedRequestHost('eviltrycloudflare.com', loopback)).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts the docker/podman container-to-host gateway aliases (in-container hooks)', () => {
|
||||
expect(isAllowedRequestHost('host.docker.internal:3000', loopback)).toBe(true);
|
||||
expect(isAllowedRequestHost('host.containers.internal:3000', loopback)).toBe(true);
|
||||
// a lookalike is still rejected (exact match only)
|
||||
expect(isAllowedRequestHost('host.docker.internal.evil.com', loopback)).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts the configured bind host when it is a hostname', () => {
|
||||
const policy: HostPolicy = { bindHost: 'mybox.local', allowedHosts: [], tunnelHost: null };
|
||||
expect(isAllowedRequestHost('mybox.local:3000', policy)).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user