Skip to content

Bind the notebook sample's container to loopback and restrict its database origins - #2382

Merged
kmcginnes merged 1 commit into
mainfrom
sagemaker-sample-loopback-and-origins
Oct 7, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
sagemaker-sample-loopback-and-origins

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Bring the SageMaker sample lifecycle script in line with our own documentation for how the notebook deployment is reached and which databases its proxy server contacts.

  • docs/guides/deploy-to-sagemaker.md describes the Jupyter proxy as the only access path to the container. The script now publishes the container port on loopback only.
  • docs/references/security.md recommends setting PROXY_SERVER_ALLOWED_DB_ORIGINS wherever the host has AWS credentials, such as a notebook instance role. The script now sets it to the configured cluster.
 NEPTUNE_URI="https://${GRAPH_NOTEBOOK_HOST}:${GRAPH_NOTEBOOK_PORT}"
+ALLOWED_DB_ORIGINS="${NEPTUNE_URI}"

 start_graph_explorer_with_cw_logs()      # and _with_default_logs()
-  docker run -d -p 9250:9250
+  docker run -d -p 127.0.0.1:9250:9250
     --env GRAPH_CONNECTION_URL=${NEPTUNE_URI}
+    --env "PROXY_SERVER_ALLOWED_DB_ORIGINS=${ALLOWED_DB_ORIGINS}"

ALLOWED_DB_ORIGINS is a variable rather than an inline value so deployers have one place to add an origin, which the guide's Network Requirements section now explains. The lifecycle log prints the effective value next to the Neptune URI.

Evidence

Before: The sample script didn't match the guide's Security model or the allowlist guidance in security.md.
After: pnpm test packages/graph-explorer-proxy-server/src/process-environment passes, 62/62. The test that mirrors the script's docker run variables picks up the new variable.

Verified live: A notebook instance booted through this script, with only its two documented placeholders filled. The container listens on 127.0.0.1:9250 and /status returns 200 over loopback. Through the Jupyter proxy the UI loads, schema sync completes, and a Gremlin query returns results that render, with every captured proxy request returning 200. A request naming a database origin outside the allowlist returns 403.

Merge Danger

Door: two-way

Each change is one line per docker run call and reverts cleanly.

Impact: deployment

Existing notebooks keep their current lifecycle configuration until it is updated, so this reaches a deployment only when its lifecycle configuration is replaced and the instance restarts. A Connection to a database other than the configured cluster then needs its origin added to ALLOWED_DB_ORIGINS, which is worth a release note. --env HOST=127.0.0.1 is left alone; it only feeds the certificate name and the startup banner.

Related

…abase origins

Bind the published port to 127.0.0.1 so the Jupyter proxy is the only
path to Graph Explorer, as deploy-to-sagemaker.md already describes.
Jupyter connects from inside the instance, so the documented path is
unaffected.

Set PROXY_SERVER_ALLOWED_DB_ORIGINS in both docker run calls so the
proxy only signs requests for the configured cluster, following the
security.md guidance for hosts with AWS credentials. The value comes
from a new ALLOWED_DB_ORIGINS variable that defaults to NEPTUNE_URI,
the cluster's bare origin, and the lifecycle log prints it.

Explain in the SageMaker guide how to add another database's origin,
since network routing alone no longer reaches it.

Add the new variable to the test that mirrors the script's docker run
variables.
@kmcginnes
kmcginnes force-pushed the sagemaker-sample-loopback-and-origins branch from 6cf0889 to d1e1392 Compare October 7, 2026 21:23

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approved

@kmcginnes
kmcginnes merged commit b454c3d into main Oct 7, 2026
3 checks passed
@kmcginnes
kmcginnes deleted the sagemaker-sample-loopback-and-origins branch October 7, 2026 21:31
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.

1 participant