-
Notifications
You must be signed in to change notification settings - Fork 21
fix: resolve host.docker.internal DNS in chroot mode for MCP servers #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
003c1e8
7f29949
a1fc991
6fce21a
d0ece8e
73e9f12
a0a1744
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -485,9 +485,28 @@ | |
| '/etc/passwd:/host/etc/passwd:ro', // User database (needed for getent/user lookup) | ||
| '/etc/group:/host/etc/group:ro', // Group database (needed for getent/group lookup) | ||
| '/etc/nsswitch.conf:/host/etc/nsswitch.conf:ro', // Name service switch config | ||
| '/etc/hosts:/host/etc/hosts:ro', // Host name resolution (localhost, etc.) | ||
| ); | ||
|
|
||
| // Mount /etc/hosts for host name resolution inside chroot | ||
| // When BOTH chroot and host access are enabled, we mount a writable COPY so the entrypoint | ||
| // can inject host.docker.internal (Docker only adds it to the container's | ||
| // /etc/hosts via extra_hosts, but chroot uses the host's /etc/hosts) | ||
| if (config.enableHostAccess) { | ||
| const chrootHostsPath = path.join(config.workDir, 'chroot-hosts'); | ||
| try { | ||
| fs.copyFileSync('/etc/hosts', chrootHostsPath); | ||
| fs.chmodSync(chrootHostsPath, 0o644); | ||
| logger.debug(`Copied /etc/hosts to ${chrootHostsPath} for chroot host access`); | ||
| } catch { | ||
| // Fall back to empty file if host /etc/hosts is not readable | ||
| fs.writeFileSync(chrootHostsPath, '127.0.0.1 localhost\n', { mode: 0o644 }); | ||
| logger.debug('Created minimal chroot-hosts (could not read host /etc/hosts)'); | ||
| } | ||
| agentVolumes.push(`${chrootHostsPath}:/host/etc/hosts`); | ||
| } else { | ||
| agentVolumes.push('/etc/hosts:/host/etc/hosts:ro'); | ||
| } | ||
|
Comment on lines
+495
to
+520
|
||
|
|
||
| // SECURITY: Hide Docker socket to prevent firewall bypass via 'docker run' | ||
| // An attacker could otherwise spawn a new container without network restrictions | ||
| agentVolumes.push('/dev/null:/host/var/run/docker.sock:ro'); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.