Skip to content

Harden dispersion entries in the artifact trust boundary - #117

Merged
isayev merged 1 commit into
mainfrom
fix/artifact-dispersion-hardening
Aug 7, 2026
Merged

Harden dispersion entries in the artifact trust boundary#117
isayev merged 1 commit into
mainfrom
fix/artifact-dispersion-hardening

Conversation

@isayev

@isayev isayev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #115, fixing the six Major findings from a three-agent security review of the dispersion allowlist additions:

  1. Forbid ptfile in artifact model_yamlDispParam.__init__ runs torch.load on that kwarg; the walker never inspected constructor kwargs, so default-trusted artifacts gained an arbitrary-path read/probe primitive. The exporter always strips it, so no legitimate artifact is affected.
  2. YAML↔metadata D3TS consistency — D3TS presence is now derived from model_yaml and must agree with has_embedded_d3ts, closing the silent dispersion double-count / silent-loss window for mislabeled artifacts.
  3. Validate D3TS damping numericsa1/a2/s8/s6 from YAML must be finite and non-negative (they live outside the state dict; NaN or zero damping previously loaded silently).
  4. Drift-class invariant — new test enforces trusted-class ⊆ frozen-ABI, plus an end-to-end fixture proving an embedded-D3TS artifact shape validates under the registry policy.
  5. Written admission rule for future default-allowlist additions, including the constructor-side-effect criterion that would have caught (1) at review time.
  6. Spelling coherenceaimnet.modules.lr.D3TS is now trusted alongside the barrel spelling (the loader detects D3TS by substring; the validator matches exactly), with the DispParam single-spelling rationale documented.

Also repairs a pre-existing test mock in test_train_utils.py that produced exactly the mislabeled shape check (2) now rejects.

Verification: security+ABI suites 228 passed; model+calculator suites 111 passed; full default suite 589 passed, 0 failed; ruff clean.

Fixes six Major findings from a three-agent security review of the artifact
trust boundary in aimnet.models.artifact_validation:

1. Forbid the ptfile constructor kwarg anywhere in artifact model_yaml.
   DispParam.__init__ runs torch.load(ptfile, weights_only=True) on a
   YAML-supplied path, and the import-path walker never inspected
   constructor kwargs, so a default-trusted artifact could carry an
   arbitrary-path read/probe/DoS primitive. The exporter already strips
   ptfile before producing an artifact, so no legitimate artifact is
   affected; training-config loading is untouched.

2. Cross-check D3TS presence between model_yaml and the has_embedded_d3ts
   metadata flag during artifact validation. The two were previously
   validated independently, so a mislabeled artifact could silently
   double-count or entirely lose dispersion depending on which direction it
   was mislabeled. Also fixed a test_train_utils.py export test whose mock
   produced exactly that mislabeled shape, now that the boundary rejects it.

3. Validate D3TS damping parameters (a1, a2, s8, s6) supplied via artifact
   model_yaml: finite, non-negative real numbers only. These are plain
   constructor floats outside the state dict, so nothing previously stopped
   a NaN/Inf value or a1=a2=0 (an undamped 1/d^6 collapse) from loading
   silently.

4. Added an invariant test pinning every default-trusted class import path
   into the frozen serialization-ABI list, plus a completeness fixture
   proving REGISTRY_IMPORT_POLICY actually admits a DispParam+D3TS artifact
   shape end-to-end.

5. Documented the admission criteria for the default class-import allowlist
   directly above its definition.

6. Trusted the aimnet.modules.lr.D3TS submodule spelling alongside the
   existing barrel spelling, matching the substring-based class detection
   already used by the loader machinery.
@isayev
isayev merged commit 704325e into main Aug 7, 2026
20 checks passed
@isayev
isayev deleted the fix/artifact-dispersion-hardening branch August 7, 2026 23:42
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