Harden the remote worker: TLS off loopback, full digests, filtered env
fluksio-worker now refuses ws:// and http:// engine and artifact URLs unless they are loopback or --insecure is given; the engine still accepts both. An artifact reference must be sha256: plus 64 hex digits before it is joined into a path, and node code gets the host environment through the engine's credential denylist instead of all of it.
This commit is contained in:
@@ -144,7 +144,7 @@ class _Reporter(ModuleType):
|
||||
def load_artifact(self, ref: dict[str, Any]) -> str:
|
||||
"""Fetch an artifact and hand back a local path to read it from."""
|
||||
digest = str((ref or {}).get("digest") or "")
|
||||
if not digest.startswith("sha256:"):
|
||||
if not _valid_digest(digest):
|
||||
raise ValueError("not an artifact reference")
|
||||
return _fetch(digest)
|
||||
|
||||
@@ -318,6 +318,16 @@ def _put_over_http(
|
||||
pass
|
||||
|
||||
|
||||
def _valid_digest(digest: str) -> bool:
|
||||
"""The engine's own check: the digest becomes part of a path below."""
|
||||
body = digest.removeprefix("sha256:")
|
||||
return (
|
||||
digest.startswith("sha256:")
|
||||
and len(body) == 64
|
||||
and all(c in "0123456789abcdef" for c in body)
|
||||
)
|
||||
|
||||
|
||||
def _fetch(digest: str) -> str:
|
||||
"""A local path holding this artifact's bytes, downloading it if needed."""
|
||||
for variable in (ARTIFACT_DIR_ENV, ARTIFACT_VOLATILE_DIR_ENV):
|
||||
|
||||
Reference in New Issue
Block a user