You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/07/27 18:07:48 UTC
(tooling-trusted-releases) 01/01: Report a concern if an artifact was not signed by the uploader
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
commit 6c88e06d110ad81a681deac128aa7fb8fd12766c
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon Jul 27 19:07:01 2026 +0100
Report a concern if an artifact was not signed by the uploader
---
atr/attestable.py | 10 +++++
atr/docs/checks.md | 4 +-
atr/tasks/__init__.py | 8 +++-
atr/tasks/checks/__init__.py | 13 ++++++
atr/tasks/checks/signature.py | 53 +++++++++++++++++++++---
tests/unit/test_attestable.py | 10 +++++
tests/unit/test_checks_signature.py | 80 ++++++++++++++++++++++++++++++++-----
7 files changed, 159 insertions(+), 19 deletions(-)
diff --git a/atr/attestable.py b/atr/attestable.py
index cc372098..eee03dae 100644
--- a/atr/attestable.py
+++ b/atr/attestable.py
@@ -359,6 +359,16 @@ def path_swhid_dir(attestable: models.Attestable, path_key: str) -> str | None:
return hash_entry.swhid_dir_inner if (hash_entry is not None) else None
+def path_uploaders(attestable: models.Attestable, path_key: str) -> list[str]:
+ content_hash = path_hash(attestable, path_key)
+ if content_hash is None:
+ return []
+ hash_entry = attestable.hashes.get(content_hash)
+ if hash_entry is None:
+ return []
+ return sorted({uid for uid, _ in hash_entry.uploaders})
+
+
async def paths_to_hashes_and_sizes(directory: pathlib.Path) -> tuple[dict[safe.RelPath, str], dict[safe.RelPath, int]]:
path_to_hash: dict[safe.RelPath, str] = {}
path_to_size: dict[safe.RelPath, int] = {}
diff --git a/atr/docs/checks.md b/atr/docs/checks.md
index c90a9daa..e1b64792 100644
--- a/atr/docs/checks.md
+++ b/atr/docs/checks.md
@@ -52,7 +52,9 @@ The checker key is `atr.tasks.checks.file_hash.check`.
For each `.asc` signature file, ATR verifies the signature against the matching artifact using the public keys stored for the release committee. The signature is accepted only when it verifies and when the signing key is associated with an ASF UID or is the committee's automated release signing key, with a primary UID containing "Automated Release Signing" or "Services RM" and the email address `private@`[_committee name_]`.apache.org`. If no suitable key is found or the signature does n [...]
-The checker key is `atr.tasks.checks.signature.check`.
+ATR also raises a concern when the ASF UID of the signing key is not one of the ASF UIDs recorded as having uploaded the artifact, because an artifact is expected to be signed by the person who uploaded it. The automated release signing key is exempt. The concern does not block a vote, but it must be acknowledged before one is started.
+
+The checker key is `atr.tasks.checks.signature.check`, and the uploader concern is recorded under `atr.tasks.checks.signature.check_uploader_mismatch`.
### Archive integrity checks
diff --git a/atr/tasks/__init__.py b/atr/tasks/__init__.py
index 5160d7a6..42c0904b 100644
--- a/atr/tasks/__init__.py
+++ b/atr/tasks/__init__.py
@@ -74,6 +74,7 @@ async def asc_checks(
tasks = []
if release.committee:
+ input_args = await checks.resolve_extra_args(signature.INPUT_EXTRA_ARGS, release, signature_path)
tasks.append(
await queued(
asf_uid,
@@ -87,10 +88,13 @@ async def asc_checks(
signature.INPUT_POLICY_KEYS,
release,
revision,
- await checks.resolve_extra_args(signature.INPUT_EXTRA_ARGS, release, signature_path),
+ input_args,
file=signature_path,
),
- extra_args={"committee_key": release.committee.key},
+ extra_args={
+ "committee_key": release.committee.key,
+ "unsuffixed_file_uploaders": input_args["unsuffixed_file_uploaders"],
+ },
)
)
diff --git a/atr/tasks/checks/__init__.py b/atr/tasks/checks/__init__.py
index 4f00c295..e814bdeb 100644
--- a/atr/tasks/checks/__init__.py
+++ b/atr/tasks/checks/__init__.py
@@ -20,6 +20,7 @@ from __future__ import annotations
import dataclasses
import datetime
import functools
+import pathlib
from typing import TYPE_CHECKING, Any, Final
import aiofiles
@@ -556,6 +557,17 @@ async def _resolve_unsuffixed_file_hash(release: sql.Release, rel_path: str | No
return ""
+async def _resolve_unsuffixed_file_uploaders(release: sql.Release, rel_path: str | None = None) -> list[str]:
+ if (not rel_path) or (not release.latest_revision_number):
+ return []
+ attestable_data = await attestable.load(
+ release.safe_project_key, release.safe_version_key, release.safe_latest_revision_number
+ )
+ if attestable_data is None:
+ return []
+ return attestable.path_uploaders(attestable_data, str(pathlib.PurePosixPath(rel_path).with_suffix("")))
+
+
_EXTRA_ARG_RESOLVERS: Final[dict[str, Callable[[sql.Release, str | None], Any]]] = {
"all_files": _resolve_all_files,
"committee_key": _resolve_committee_key,
@@ -565,4 +577,5 @@ _EXTRA_ARG_RESOLVERS: Final[dict[str, Callable[[sql.Release, str | None], Any]]]
"is_podling": _resolve_is_podling,
"suffixed_file_existence": _resolve_suffixed_file_existence,
"unsuffixed_file_hash": _resolve_unsuffixed_file_hash,
+ "unsuffixed_file_uploaders": _resolve_unsuffixed_file_uploaders,
}
diff --git a/atr/tasks/checks/signature.py b/atr/tasks/checks/signature.py
index 53891378..422136c2 100644
--- a/atr/tasks/checks/signature.py
+++ b/atr/tasks/checks/signature.py
@@ -33,8 +33,13 @@ import atr.util as util
# Release policy fields which this check relies on - used for result caching
INPUT_POLICY_KEYS: Final[list[str]] = []
-INPUT_EXTRA_ARGS: Final[list[str]] = ["committee_key", "committee_signing_keys", "unsuffixed_file_hash"]
-CHECK_VERSION: Final[str] = "7"
+INPUT_EXTRA_ARGS: Final[list[str]] = [
+ "committee_key",
+ "committee_signing_keys",
+ "unsuffixed_file_hash",
+ "unsuffixed_file_uploaders",
+]
+CHECK_VERSION: Final[str] = "8"
async def check(args: checks.FunctionArguments) -> results.Results | None:
@@ -61,11 +66,13 @@ async def check(args: checks.FunctionArguments) -> results.Results | None:
f" using {committee_key} keys (rel: {primary_rel_path})"
)
+ uploader_uids = set(args.extra_args.get("unsuffixed_file_uploaders", []))
try:
result_data = await _check_core_logic(
committee_key=committee_key,
artifact_path=str(artifact_abs_path),
signature_path=str(primary_abs_path),
+ uploader_uids=uploader_uids,
)
except Exception as e:
await recorder.exception("Error during signature check execution", {"error": str(e)})
@@ -76,13 +83,17 @@ async def check(args: checks.FunctionArguments) -> results.Results | None:
await recorder.blocker(error, result_data)
case _ if result_data.get("verified"):
await recorder.note("Signature verified successfully", result_data)
+ if not result_data["signer_is_uploader"]:
+ await _record_uploader_concern(args, recorder, uploader_uids, result_data)
case _:
await recorder.exception("Signature verification failed for unknown reasons", result_data)
return None
-async def _check_core_logic(committee_key: str, artifact_path: str, signature_path: str) -> dict[str, Any]:
+async def _check_core_logic(
+ committee_key: str, artifact_path: str, signature_path: str, uploader_uids: set[str]
+) -> dict[str, Any]:
"""Verify a signature file using the committee's public signing keys."""
log.info(f"Attempting to fetch keys for committee_key: '{committee_key}'")
async with db.session() as session:
@@ -99,11 +110,15 @@ async def _check_core_logic(committee_key: str, artifact_path: str, signature_pa
db_public_keys = result.scalars().all()
log.info(f"Found {len(db_public_keys)} public keys for committee_key: '{committee_key}'")
apache_uid_map = {}
+ uploader_fingerprints = set()
for key in db_public_keys:
if not key.fingerprint:
continue
+ fingerprint = key.fingerprint.lower()
automated = util.is_automated_release_signing_uid(key.primary_declared_uid, committee_key)
- apache_uid_map[key.fingerprint.lower()] = bool(key.apache_uid) or automated
+ apache_uid_map[fingerprint] = bool(key.apache_uid) or automated
+ if automated or (key.apache_uid in uploader_uids):
+ uploader_fingerprints.add(fingerprint)
public_keys = [key.ascii_armored_key for key in db_public_keys]
for i, key in enumerate(public_keys):
@@ -116,11 +131,16 @@ async def _check_core_logic(committee_key: str, artifact_path: str, signature_pa
artifact_path=artifact_path,
ascii_armored_keys=public_keys,
apache_uid_map=apache_uid_map,
+ uploader_fingerprints=uploader_fingerprints,
)
def _check_core_logic_verify_signature(
- signature_path: str, artifact_path: str, ascii_armored_keys: list[str], apache_uid_map: dict[str, bool]
+ signature_path: str,
+ artifact_path: str,
+ ascii_armored_keys: list[str],
+ apache_uid_map: dict[str, bool],
+ uploader_fingerprints: set[str],
) -> dict[str, Any]:
"""Verify an OpenPGP signature for a file."""
start = time.perf_counter_ns()
@@ -228,6 +248,7 @@ def _check_core_logic_verify_signature(
# provenance is recorded from this, so it must not be widened to the certificate
"fingerprint": status.fingerprint,
"certificate_fingerprint": matched_key.fingerprint.lower(),
+ "signer_is_uploader": matched_key.fingerprint.lower() in uploader_fingerprints,
"status": "Valid signature",
"debug_info": debug_info,
}
@@ -410,6 +431,28 @@ def _parse_public_keys(ascii_armored_keys: list[str]) -> list[openpgp.PublicKey]
return public_keys
+async def _record_uploader_concern(
+ args: checks.FunctionArguments,
+ recorder: checks.Recorder,
+ uploader_uids: set[str],
+ result_data: dict[str, Any],
+) -> None:
+ uploader_recorder = await checks.Recorder.create(
+ checker=checks.function_key(check) + "_uploader_mismatch",
+ checker_version=CHECK_VERSION,
+ inputs_hash=recorder.input_hash or "",
+ project_key=args.project_key,
+ version_key=args.version_key,
+ revision_number=args.revision_number,
+ primary_rel_path=args.primary_rel_path,
+ afresh=False,
+ )
+ await uploader_recorder.concern(
+ "The artifact was not uploaded by the owner of the signing key",
+ {**result_data, "uploader_uids": sorted(uploader_uids)},
+ )
+
+
def _revoked_key_result(
*,
matched_key: openpgp.PublicKey,
diff --git a/tests/unit/test_attestable.py b/tests/unit/test_attestable.py
index 36e2a967..44cd90ef 100644
--- a/tests/unit/test_attestable.py
+++ b/tests/unit/test_attestable.py
@@ -353,3 +353,13 @@ def test_path_provenance_returns_none_for_v1():
v1 = models.AttestableV1(paths={"a.tar.gz": "h1"})
assert attestable.path_provenance(v1, "a.tar.gz") is None
+
+
+def test_path_uploaders_deduplicates_across_revisions():
+ v2 = models.AttestableV2(
+ paths={"a.tar.gz": models.PathEntryV2(content_hash="h1", classification="source")},
+ hashes={"h1": models.HashEntryV2(size=100, uploaders=[("bob", "00002"), ("alice", "00001")])},
+ )
+
+ assert attestable.path_uploaders(v2, "a.tar.gz") == ["alice", "bob"]
+ assert attestable.path_uploaders(v2, "missing") == []
diff --git a/tests/unit/test_checks_signature.py b/tests/unit/test_checks_signature.py
index c1d53161..57096be8 100644
--- a/tests/unit/test_checks_signature.py
+++ b/tests/unit/test_checks_signature.py
@@ -259,7 +259,7 @@ async def test_check_blocks_on_missing_signature_error_kind(
]
-def test_check_core_logic_verifies_signature_signed_by_signing_subkey(tmp_path: pathlib.Path) -> None:
+def test_check_core_logic_flags_a_signature_from_a_non_uploader(tmp_path: pathlib.Path) -> None:
signature_path, artifact_path = _write_embedded_signature_fixture(tmp_path)
result = signature_check._check_core_logic_verify_signature(
@@ -267,11 +267,28 @@ def test_check_core_logic_verifies_signature_signed_by_signing_subkey(tmp_path:
artifact_path=artifact_path,
ascii_armored_keys=[_EMBEDDED_PUBLIC_KEY_ASC],
apache_uid_map={_PRIMARY_FINGERPRINT: True},
+ uploader_fingerprints=set(),
)
assert result["verified"] is True
- assert result["status"] == "Valid signature"
- assert result["key_id"] == _SIGNING_SUBKEY_ID
+ assert result["signer_is_uploader"] is False
+
+
+def test_check_core_logic_rejects_signature_from_a_revoked_subkey(tmp_path: pathlib.Path) -> None:
+ # The signature was made while the subkey was still good, so it verifies cryptographically and
+ # only a revocation check can reject it
+ signature_path, artifact_path = pgp_fixtures.write_revoked_subkey_fixture(tmp_path)
+
+ result = signature_check._check_core_logic_verify_signature(
+ signature_path=signature_path,
+ artifact_path=artifact_path,
+ ascii_armored_keys=[pgp_fixtures.REVOKED_SUBKEY_PUBLIC_KEY_ASC],
+ apache_uid_map={pgp_fixtures.REVOKED_SUBKEY_PRIMARY_FINGERPRINT: True},
+ uploader_fingerprints={pgp_fixtures.REVOKED_SUBKEY_PRIMARY_FINGERPRINT},
+ )
+
+ assert result["verified"] is False
+ assert result["error_kind"] == "revoked_key"
def test_check_core_logic_rejects_signature_from_an_expired_subkey(tmp_path: pathlib.Path) -> None:
@@ -282,26 +299,67 @@ def test_check_core_logic_rejects_signature_from_an_expired_subkey(tmp_path: pat
artifact_path=artifact_path,
ascii_armored_keys=[pgp_fixtures.EXPIRED_SUBKEY_PUBLIC_KEY_ASC],
apache_uid_map={pgp_fixtures.EXPIRED_SUBKEY_PRIMARY_FINGERPRINT: True},
+ uploader_fingerprints={pgp_fixtures.EXPIRED_SUBKEY_PRIMARY_FINGERPRINT},
)
assert result["verified"] is False
assert result["error_kind"] == "key_expired"
-def test_check_core_logic_rejects_signature_from_a_revoked_subkey(tmp_path: pathlib.Path) -> None:
- # The signature was made while the subkey was still good, so it verifies cryptographically and
- # only a revocation check can reject it
- signature_path, artifact_path = pgp_fixtures.write_revoked_subkey_fixture(tmp_path)
+def test_check_core_logic_verifies_signature_signed_by_signing_subkey(tmp_path: pathlib.Path) -> None:
+ signature_path, artifact_path = _write_embedded_signature_fixture(tmp_path)
result = signature_check._check_core_logic_verify_signature(
signature_path=signature_path,
artifact_path=artifact_path,
- ascii_armored_keys=[pgp_fixtures.REVOKED_SUBKEY_PUBLIC_KEY_ASC],
- apache_uid_map={pgp_fixtures.REVOKED_SUBKEY_PRIMARY_FINGERPRINT: True},
+ ascii_armored_keys=[_EMBEDDED_PUBLIC_KEY_ASC],
+ apache_uid_map={_PRIMARY_FINGERPRINT: True},
+ uploader_fingerprints={_PRIMARY_FINGERPRINT},
)
- assert result["verified"] is False
- assert result["error_kind"] == "revoked_key"
+ assert result["verified"] is True
+ assert result["status"] == "Valid signature"
+ assert result["key_id"] == _SIGNING_SUBKEY_ID
+ assert result["signer_is_uploader"] is True
+
+
+async def test_check_records_a_concern_when_the_signer_did_not_upload(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path
+) -> None:
+ signature_path = tmp_path / "artifact.tar.gz.asc"
+ signature_path.write_text("not a signature", encoding="utf-8")
+ recorder = SignatureRecorderStub(signature_path, tmp_path, "atr.tasks.checks.signature.check")
+ recorded_concerns = []
+
+ async def check_core_logic(**kwargs: object) -> dict[str, object]:
+ del kwargs
+ return {"verified": True, "signer_is_uploader": False}
+
+ async def record_uploader_concern(*called_with: object) -> None:
+ recorded_concerns.append(called_with)
+
+ monkeypatch.setattr(signature_check, "_check_core_logic", check_core_logic)
+ monkeypatch.setattr(signature_check, "_record_uploader_concern", record_uploader_concern)
+ args = checks.FunctionArguments(
+ recorder=recorders.get_recorder(recorder),
+ asf_uid="tester",
+ project_key=safe.ProjectKey("test"),
+ version_key=safe.VersionKey("1.0"),
+ revision_number=safe.RevisionNumber("00001"),
+ primary_rel_path=safe.RelPath(signature_path.name),
+ extra_args={"committee_key": "test", "unsuffixed_file_uploaders": ["alice"]},
+ )
+
+ await signature_check.check(args)
+
+ assert recorder.messages == [
+ (
+ sql.CheckResultStatus.NOTE.value,
+ "Signature verified successfully",
+ {"verified": True, "signer_is_uploader": False},
+ )
+ ]
+ assert len(recorded_concerns) == 1
def test_key_matches_signature_accepts_subkey_issuer_metadata() -> None:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org