fix(frontend): scope archived pod-log reads to the authorized namespace#104
fix(frontend): scope archived pod-log reads to the authorized namespace#104herikwebb wants to merge 18 commits into
Conversation
Signed-off-by: Herik Webb <herik@shardplate.local>
Signed-off-by: Herik Webb <herik@shardplate.local>
Add a pull request watch policy so that any agent (including scheduled routines) subscribes to a PR immediately after opening it, handing it to the persistent watcher for review-feedback and CI follow-up until the PR is merged or closed. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
…tter Codify that every commit must be authored, committed, and signed off by the human submitter rather than an agent identity. Automated environments default the git identity to the agent (e.g. Claude <noreply@anthropic.com>), so a bare 'git commit -s' signs off as the agent and breaks the DCO requirement. Document setting the repo-local identity to the submitter, verifying author and sign-off before pushing, and reusing the submitter identity for follow-up commits on a PR they already authored. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
gpt-5.5 is a reasoning model whose reasoning tokens count against max_output_tokens, so the previous 3000 budget was intermittently exhausted before any review text was produced, failing the review job with 'OpenAI API response did not include review text'. Raise the default to 16000 and make it overridable via the OPENAI_MAX_OUTPUT_TOKENS repository variable. Also export the variable in review-pr.sh so the python child process actually inherits it — previously it was set without export, so the child always used its own hardcoded default regardless of the shell value. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
Raising the token budget means a review can exceed GitHub's 65536-character comment body limit, which would make 'gh pr comment' fail after a successful model call. Truncate the body (with margin) and append a notice when it is too large instead of failing to post the review. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
`resolveFilePathOnVolume` in `frontend/server/utils.ts` composed the final filesystem path with `path.join(volumeMountPath, filePathInVolume)`, which collapses `..` segments. `getArtifactsHandler` in `frontend/server/handlers/artifacts.ts` validates the `bucket` query param with `isAllowedResourceName` but only length-caps the `key` param and hands it to `getVolumeArtifactsHandler` → `findFileOnPodVolume` → `resolveFilePathOnVolume` unchanged. Combined with a well-known volume name mounted on the ml-pipeline-ui pod (for example `config-volume` from `manifests/kustomize/base/pipeline/ml-pipeline-ui-deployment.yaml`), an authenticated Kubeflow user could pass `?source=volume&bucket=config-volume&key=../../var/run/secrets/kubernetes.io/serviceaccount/token` through the artifacts auth middleware — which only checks that they can access their own namespace — and stream the ml-pipeline-ui pod's service account token (or any other file the pod's filesystem contains). Normalize the joined path with `path.resolve` and require that it stays under the resolved `volumeMountPath` (equal to it or under `volumeMountPath + '/'`). This blocks both `../` escapes when no `subPath` is set and `subPath + '/../../'` escapes when `subPath` is configured. Add two `resolveFilePathOnVolume` regression tests covering both variants. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
…eads The lexical path.resolve containment check in resolveFilePathOnVolume stops '..' traversal but not a symlink inside the mounted volume pointing outside it (e.g. 'link -> /etc/passwd'), which fs.createReadStream would follow at read time. Add resolveRealPathWithinMount, which resolves the real (symlink-free) path immediately before the read and re-verifies it stays within the volume mount, minimizing the TOCTOU window by returning the fully resolved path to open. findFileOnPodVolume now also returns the resolved volume mount path so the read site can perform this check; the extra tuple element is backward compatible with existing two-element destructures. getVolumeArtifactsHandler calls the resolver before stat/createReadStream and reads the returned safe path. When the path cannot be resolved (missing file) the original path is returned so existing not-found behavior is preserved. Extract a shared isPathInsideMount helper used by both the lexical and the realpath containment checks. Add resolveRealPathWithinMount tests covering an in-mount file, a symlink escaping the mount, and an unresolvable path. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
The previous fix resolved the real path and re-checked containment, but the handler then reopened that path with stat()/createReadStream(). An attacker able to write the volume could swap the file for a symlink between the check and the open, and both calls follow symlinks, so the read could still escape. Replace resolveRealPathWithinMount with openRealFileWithinMount, which opens the file once, verifies the opened descriptor's real target (via /proc/self/fd on Linux, falling back to path resolution elsewhere) is inside the mount, and returns the handle. getVolumeArtifactsHandler streams from that same handle instead of reopening by name, so validation and read act on one fd and cannot be raced. Open errors (missing file) still propagate to preserve the existing not-found behavior. Update tests to cover the open-and-validate handle, symlink rejection, and missing-file propagation. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
Match the notebook-intelligence PR reviewer: - Trigger on pull_request instead of pull_request_target and check out the PR head directly (fork PRs get a read-only token and no secrets, so running the diff-only reviewer on the checked-out head is safe and simpler). - Emit a machine-readable VERDICT (APPROVE / CHANGES_REQUESTED) and fail the check on a non-APPROVE verdict, so a green 'review' check means the reviewer signed off. This is what an automated promotion can key off. - Add an 'override-review-gate' label escape hatch that relaxes only the exit status; the review still runs and comments. - Use a three-dot (merge-base) diff range with a two-dot fallback on shallow clones, so the reviewer sees what the PR introduces on merge. Keeps the fork's OPENAI_MAX_OUTPUT_TOKENS=16000 override: gpt-5.5 is a reasoning model and 3000 was easily exhausted, producing empty responses that would now fail the review gate. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
Add a workflow_dispatch action + scripts/promote-upstream.sh that opens a cross-fork PR from a chosen fork branch into kubeflow/pipelines, using a human PAT (secrets.UPSTREAM_PAT) since the default GITHUB_TOKEN cannot write upstream. It resolves the upstream default branch, refuses empty promotions, guards against leaking fork-only automation files into the upstream diff, and by default requires the branch's fork PR review gate to be green before promoting (override with require_review_pass=false). Change detection uses GitHub's server-side compare API so it is independent of local clone depth. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
promote-upstream.sh used GitHub's compare API only and never rebased, so a fix branch cut from the fork's default branch dragged the fork-only automation (pr-review.yml, this script, AGENTS.md, ...) into the upstream compare and tripped the fork-only guard — the same branch could not serve both the fork review PR and the upstream promotion. Add an optional FORK_BASE input: when set (e.g. master), replay only the commits the branch adds over that base onto the current upstream tip, push the result as a script-managed derived branch, and promote that. The review gate still keys off the original fork PR branch. Blank FORK_BASE preserves the previous promote-as-is behavior.
The derive step now cherry-picks with --signoff so the promoted commits carry a Signed-off-by trailer for the submitter identity, satisfying kubeflow/pipelines' DCO requirement without a manual re-sign. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
With more than one fix commit GitHub falls back to the branch name for the PR title and an empty description. Default the promotion PR title/body from the primary (first) fix commit instead of the branch tip, list the included commits, and append the sign-off / title-convention checklist. Add a body input to the workflow so it can be overridden. No squashing: upstream squash-merges anyway, so the PR title/body is what becomes the merge commit. Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
The ml-pipeline-ui pod-logs handler authorizes access against the
caller-supplied `podnamespace`, but the archive fallback
(getPodLogsStreamFromArchive) derives the object key entirely from the
caller-supplied `podname`/`createdat` via the configured keyFormat. The
default keyFormat is not namespace-scoped, so in multi-user mode an
authenticated tenant could read another tenant's archived pod logs from
the shared bucket by naming the target pod — the namespace access check
does not constrain the archive object key.
Fail closed in multi-user mode: require the keyFormat to embed
{{workflow.namespace}} (and a non-empty namespace) so the resolved key
stays confined to the authorized namespace prefix, and reject any '..'
path segment so a caller-controlled podname cannot climb out of that
prefix. Behavior is unchanged when auth is disabled.
Adds unit tests for namespace-scoped keys, the fail-closed paths, and
the '..' rejection.
Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
Automated PR ReviewModel: Changed files: Review result: Automated review findingsHigh —
|
Address review feedback: the multi-user archive-key guard previously only
checked that {{workflow.namespace}} appeared anywhere in the keyFormat.
A template placing it adjacent to a caller-controlled field (e.g.
"{{workflow.namespace}}{{pod.name}}" or "{{workflow.namespace}}-{{pod.name}}")
would pass while still letting a tenant in namespace "foo" construct keys
overlapping "foobar"/"foo-bar".
Require {{workflow.namespace}} to be a complete '/'-delimited path segment
(matching (^|/){{workflow.namespace}}(/|$)) so the authorized namespace forms
an unambiguous prefix/segment. Add tests for concatenated and delimiter-adjacent
templates (rejected) and a trailing namespace segment (accepted).
Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
|
Thanks — good catch. Fixed in f3c65fe.
Added tests for the concatenated and delimiter-adjacent templates (both rejected) and for a trailing namespace segment (accepted). Generated by Claude Code |
Automated PR ReviewModel: Changed files: Review result: Automated review findings
|
Address review feedback: the previous change hardened only the configured archive fallback, but composePodLogsStreamHandler attempts getPodLogsStreamFromWorkflow first. That path reads the main-logs artifact s3.key from the workflow status and fetches it with the shared object-store credentials, without confining the key to the authorized namespace. A tenant who can influence their namespace's artifact-repositories keyFormat could point the recorded main-logs key at another namespace's log object and read it, bypassing the fallback guard. Thread authEnabled into getPodLogsMinioRequestConfigfromWorkflow and, in multi-user mode, require the workflow-recorded log key to contain the authorized namespace as a complete '/'-delimited path segment (rejecting '..'), mirroring the archive-fallback check. Bind authEnabled where the handler composes the workflow-status stream. Adds regression tests for an unscoped/cross-namespace key (rejected) and a namespace-scoped key (accepted). Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
|
Good catch — fixed in 7b2133d. You're right that
Generated by Claude Code |
Automated PR ReviewModel: Changed files: Review result: Automated findingsHigh —
|
Address review feedback: requiring {{workflow.namespace}} to appear merely as
some '/'-delimited segment did not prove the key was scoped to that namespace —
a key from another namespace could coincidentally contain the authorized
namespace as a later segment (e.g. a workflow-name or pod-derived segment).
Introduce a shared namespaceScopedKeyPrefix() helper that returns the deterministic
namespace-scoped prefix only when {{workflow.namespace}} is a complete '/'-delimited
segment ahead of every caller-influenced field (pod name, workflow name, creation
timestamp), and null otherwise. Both archived-log paths now use it:
- createPodLogsMinioRequestConfig fails closed unless the (operator/config) keyFormat
yields such a prefix.
- getPodLogsMinioRequestConfigfromWorkflow receives the trusted operator keyFormat and
requires the workflow-recorded key to begin with the derived namespace prefix (and
rejects '..'), so a tenant-influenced artifact key cannot point at another namespace's
object.
Update tests: a template placing a caller field before the namespace tag (including a
trailing namespace segment) is now rejected; add coverage for a bounded prefix segment,
the workflow-status prefix match, and fail-closed when the trusted keyFormat is not
namespace-scoped.
Signed-off-by: Herik Webb <herikwebb@users.noreply.github.com>
|
Agreed — presence-as-a-segment doesn't prove scoping. Fixed in f9c2651. Added a shared
Test updates: a template placing a caller field before the namespace tag (including a trailing-segment namespace) is now rejected; added coverage for a bounded prefix segment, the workflow-status prefix match, and fail-closed when the trusted keyFormat isn't namespace-scoped. 22 tests pass; Note on the workflow-status path: it now validates against the operator's global Generated by Claude Code |
Automated PR ReviewModel: Changed files: Review result: No automated findings were found in the changed code. Residual risks: the new namespace-scoping checks are security-sensitive and depend on the configured |
8e96fb2 to
a68c3e7
Compare
Summary
The
ml-pipeline-uipod-logs handler authorizes access against the caller-suppliedpodnamespace, but the archive fallback (getPodLogsStreamFromArchive) derives the object-store key entirely from the caller-suppliedpodname/createdatvia the configuredkeyFormat. The shipped defaultkeyFormatis not namespace-scoped, so in multi-user mode the namespace access check does not constrain which archived log is returned, and an authenticated tenant could read another tenant's archived pod logs from the shared bucket.Change
In
createPodLogsMinioRequestConfig, fail closed when auth is enabled:namespaceand require thekeyFormatto embed{{workflow.namespace}}, so the resolved key stays confined to the authorized namespace prefix. If the key template is not namespace-scoped, refuse the archive read instead of serving an unscoped key...path segment in the resolved key so a caller-controlledpodnamecannot climb out of the namespace prefix (the existing regex allows.and/).Behavior is unchanged when auth is disabled (single-user / standalone).
Tests
Adds
frontend/serverunit tests for the namespace-scoped key, both fail-closed paths, and the..rejection.workflow-helpervitest suite passes;tsc --noEmitand Prettier are clean on the changed files.Tracking / disclosure
Tracking issue: #103
Per
kubeflow/pipelinesSECURITY.md, coordinated disclosure should go through the upstream private channel (a GitHub Security Advisory onkubeflow/pipelinesorksc@kubeflow.org); this fork PR is the review/tracking record and is not for merge here.Generated by Claude Code