Bind task secrets to workspace and name, and stop sending them over plain http

Open
#70 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, python

Research direction

Start with the named keyring and task secret service code, then inspect the key rotation CLI and worker config and task execution paths. Read the existing task secret tests and run them to understand encryption, rotation, and secret delivery. Done means the acceptance criteria pass, including legacy secret compatibility, visible failure for mismatched envelopes, safe warnings for non-loopback HTTP, and the requested documentation and changelog updates.

Written by the indexing model from the issue text.

Description

client enhancement P1 server

Problem

A stored task secret should belong to one workspace and one name, and a worker should not receive it over a channel that anyone on the path can read. Three gaps remain.

  1. The fingerprint key is global. The fingerprint is an HMAC over the value only, with one key derived from the primary key (server/orcaster_server/task_secrets/keyring.py:113-118, server/orcaster_server/task_secrets/keyring.py:139). Equal values in two workspaces show equal fingerprints. A user who belongs to both can tell that the values match, or test a guess by setting a candidate value in one workspace and comparing.
  2. The ciphertext is not bound to (workspace_id, name). set_secret encrypts the bare value (server/orcaster_server/task_secrets/service.py:448), and resolve_for_task decrypts without checking the workspace or the name (server/orcaster_server/task_secrets/service.py:554). A ciphertext copied to another row by a manual SQL fix or a bad partial restore is delivered to the wrong tasks with no error.
  3. Secrets go over plain http without refusal. The worker accepts any BASE_URL scheme (client/src/orcaster_worker/config.py:147-151) and nothing checks it before a task with secrets runs. A worker set up with a non-loopback http:// URL receives every secret of its tasks in cleartext.

Proposed change

  1. Fingerprint. Compute the HMAC over workspace_id || 0x00 || name || 0x00 || value. rotate_all already recomputes every fingerprint (server/orcaster_server/cli/task_secrets_keys.py:123-157).
  2. Ciphertext. Encrypt a small envelope, for example {"ws": ..., "name": ..., "v": ...}. Mark the envelope with a version prefix byte that is not valid UTF-8 and that a legacy plaintext cannot produce. Do not use a format column instead: an old server ignores the column and would deliver the envelope text as the secret value, with no error. Never detect the format by trying to parse the plaintext as JSON: a legacy secret whose value is itself a JSON object (even one with ws, name or v keys) must stay a legacy value. On read, check ws and name. A mismatch raises UndecryptableTaskSecrets (server/orcaster_server/task_secrets/service.py:34). Rows written before this change hold the bare value and have no marker, so every reader accepts both forms: resolve_for_task, rotate_all and the ciphertext check in server/orcaster_server/cli/task_secrets_keys.py:105. rotate_all rewrites legacy rows in the envelope form.
  3. Plain http. On the worker, when BASE_URL uses http and the host is not loopback, log a warning at startup and for each task that carries secrets. In a later release, fail such a task unless an explicit opt-in is set (for example ORCH_ALLOW_INSECURE_SECRETS=true). Local development URLs such as http://host.containers.internal:8000 (docs/user-manual.md:531) must keep working, through the opt-in or an allow-list.

Compatibility

  • Existing stored secrets keep decrypting: the read path accepts the legacy bare value and the envelope. No task fails with UndecryptableTaskSecrets after the upgrade.
  • Fingerprints of existing rows change only after rotate_all runs, or when a secret is set again. Legacy rows stay unbound to workspace and name until then. The release note says that fingerprints change once.
  • Workers with an https:// BASE_URL see no change. Workers with a non-loopback http:// URL only get a warning in the first release. The refusal comes in a later release and the CHANGELOG announces it, with the opt-in.
  • A downgrade cannot read envelopes: the prefix byte makes the old UTF-8 decode fail, so the old server raises UndecryptableTaskSecrets (server/orcaster_server/task_secrets/service.py:555) instead of delivering a wrong value. Envelopes are written by rotate_all and also by every set_secret on the new version, so any secret set or rotated after the upgrade is unreadable after a downgrade. The release note says this and says to keep a database backup before the upgrade.

Acceptance criteria

  • Two workspaces that store the same value show different fingerprints (test).
  • A ciphertext copied to another workspace or another name is not decrypted, and the delivery fails visibly (test).
  • A row written in the legacy bare form still decrypts and is delivered (test).
  • A legacy row whose value is a JSON object, including one with ws, name and v keys, still decrypts and is delivered unchanged (test).
  • With an envelope row, the previous release's read path fails with UndecryptableTaskSecrets and does not deliver the envelope text (test or documented check).
  • rotate_all turns legacy rows into envelopes and recomputes their fingerprints (test).
  • A worker with a non-loopback http:// BASE_URL logs a warning that names the risk and never the values (test). Loopback URLs log nothing.
  • Existing deployments keep working without config changes: stored secrets decrypt and http:// workers still run their tasks in this release.
  • client/README.md and docs/user-manual.md document the opt-in and the planned refusal.
  • CHANGELOG entry under Unreleased, including the fingerprint change and the planned refusal.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.