# GHSA-8XCM-66JC-QMFR: mms host drift hash is an unkeyed SHA-256 over server env values and is printed in reports

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-11-15
- Modified: 2026-11-15

## Affected versions

- memtomem-stm (PyPI): from 0.1.22, through 0.7.8

## Description

## Summary

`mms/drift.py` `compute_drift_hash` returned `sha256:` + the first 16 hex chars of SHA-256 over a server's canonical form, which includes `command`, `args` and the full `env` mapping with values. Host configs often carry credentials in `env`. The hash was:

- persisted in `~/.mms/import_state.toml` (`drift_hash`), and
- printed by `mms host status --json` as `baseline_hash` / `current_hash`, and by `mms host sync --json` in `plan.remove[]`, `plan.cleanup[]` and `plan.skipped_changed[]`. The text output never carried it.

## Impact

Someone who sees a report (pasted into an issue, a chat or CI logs) and knows the rest of the server entry (often a shared template) can confirm a guessed credential value offline by recomputing the 64-bit digest. A reader of the report does not need access to the machine.

Measured on 0.7.8 with a throwaway `HOME`: the digest computed outside the package from a correct guess appears 5 times in `mms host status --json` and 3 times in `mms host sync --plan --json` for a three-entry config; a wrong guess appears 0 times.

## Fix

The drift hash is an HMAC under a random installation-local key kept in `~/.mms/import_state.toml.key` (mode `0600`), and no unkeyed value is printed.

- Hash version 2 is an HMAC over the version 1 digest string, so a stored version 1 row is re-keyed without the server shape it was computed from.
- Rows written by earlier versions are still compared by the old rule, so every entry keeps its drift state across the upgrade. The next `mms host sync --apply`, or an `mms import --apply` that finds a host definition, re-keys them in place; a `changed` entry stays `changed`.
- Each keyed row records the id of the key that stamped it. After a lost or replaced key the rows read `no_baseline`, not `changed`.
- `mms host status` and `mms host sync --plan` neither create the key nor change its mode. `--apply` creates it only after its gates have passed and before the first write. A key file that exists but cannot be used is an error and is never overwritten.
- The sidecar moves to `schema_version = 2`. An unkeyed `sha256:` hash is accepted for hash version 1 only.

On the fix commit the same measurement gives 0 occurrences in status, plan and apply output and in the rewritten sidecar.

## Limits

- Reports already shared stay checkable. Rotate a credential whose entry appeared in a report that left the machine.
- The key sits beside `~/.mms/registry.toml`, which holds the same `env` values in plain text. Keying covers reports and copies of the sidecar that leave the machine, not a copy of the whole directory.
- Until the first `--apply` that writes after upgrading, the sidecar still holds the version 1 values (they are not printed).

## Notes

Found while reviewing the fix for issue #1381 (keyed surfacing query digest). Related hardening for local stores: issue #1416.

## References

- https://github.com/memtomem/memtomem-stm/security/advisories/GHSA-8xcm-66jc-qmfr

Page: https://cve.now/GHSA-8XCM-66JC-QMFR

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
