Skip to content
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

DNS and TLS proxy #43

Merged
merged 2 commits into from
Feb 11, 2025
Merged

DNS and TLS proxy #43

merged 2 commits into from
Feb 11, 2025

Conversation

kgrofelnik
Copy link
Collaborator

@kgrofelnik kgrofelnik commented Feb 11, 2025

Overview

This PR introduces a host-side networking proxy that facilitates DNS resolution and traffic forwarding between a Nitro Enclave and external services. It ensures that:

  • DNS queries from the enclave are forwarded via vsock to the host and then resolved using system DNS.
  • TLS (HTTPS) requests from the enclave are forwarded to their original destinations using a host-side proxy.

Implementation details

DNS Forwarder (dns_forwarder.py)

  • listens on vsock port 5053, receiving DNS queries from the enclave.
  • extracts the system’s primary DNS server from /etc/resolv.conf.
  • forwards DNS requests to a public DNS resolver (system-configured or Google 8.8.8.8).
  • returns the resolved IP to the enclave via vsock.

Traffic Forwarder (traffic_forwarder.py)

  • listens on vsock port 8001, handling HTTPS requests from the enclave.
  • extracts the original IP and port from incoming packets (pre-pended by the enclave proxy).
  • forwards traffic to its actual destination over the internet.


class HostProxy:
BUFFER_SIZE = 1024
CID = 3 # The CID of the enclave
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could the enclave CID be a constant? There should also be multiple CIDs for multiple enclaves, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, but according to the usage, the vsock_server.bind((self.CID, self.PORT)) should be connecting to the enclave IIUC. so here shouldn't we provide the enclave CID?

Copy link
Collaborator Author

@kgrofelnik kgrofelnik Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this line doesn't open a connection to an enclave; instead, it binds the socket to a specific address pair (CID, PORT) so it can wait for incoming connections from enclaves.

@kgrofelnik kgrofelnik merged commit ca2c7ee into main Feb 11, 2025
5 checks passed
@kgrofelnik kgrofelnik deleted the kresimir/better_proxy branch February 11, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants