Skip to content

Fix assertion failure after a binary MAC check failure - #1815

Merged
mkskeller merged 1 commit into
data61:masterfrom
RonTuretzky:fix-mac-failure-missing-key-file
Nov 20, 2026
Merged

mkskeller merged 1 commit into
data61:masterfrom
RonTuretzky:fix-mac-failure-missing-key-file

Conversation

@RonTuretzky

Copy link
Copy Markdown
Contributor

Fixes #1814. Related: #1789 / e0ee046, which fixed the arithmetic-share case.

When a MAC check on Tinier (binary) shares failed in mascot-party.x or tinier-party.x, every party aborted with Assertion failed: (unlink(filename.c_str()) == 0), function mac_fail_remove instead of stopping with MacCheck Failure. With on-demand preprocessing, the binary MAC key secrets file was also left on disk.

Cause:

  • TinierSecret's set_secrets_filename() (inherited from VectorSecret) only registers the file name on Share<T>, not on TinierShare<T>.
  • mac_fail_remove<TinierShare<T>>() therefore falls back to get_ot_secrets_filename<TinierShare<T>>(). That gives Mascot-Secrets-B-8-..., while key generation writes Mascot-Secrets-B-64-....
  • The unlink() result was asserted, so the missing file aborted the process before throw mac_fail().

Changes:

  1. GC/TinierSecret.h: set_secrets_filename() also registers the name on the part type (TinierShare<T>). With on-demand preprocessing, a failed binary MAC check now removes the B-64 file that holds the key.
  2. Protocols/MAC_Check.hpp: mac_fail_remove() calls unlink() outside assert(). If it fails, it prints Could not remove <file>: <strerror> and still throws mac_fail. This also covers file-based preprocessing without a matching secrets file. Builds with -DNDEBUG no longer skip the removal.

The MAC check itself is unchanged. A failed check always ends in mac_fail, and the secrets file is still removed wherever it exists.

Tested on macOS arm64 with Apple clang 17. Built mascot-party.x mascot-offline.x tinier-party.x tiny-party.x spdz2k-party.x semi-offline.x with the default -Werror. Ran two parties on localhost with the program from the issue (sbits XOR + reveal):

Run Before After
mascot-party.x -o mac_fail (on-demand prep) abort (134), Mascot-Secrets-B-64-* kept MacCheck Failure (exit 1), Mascot-Secrets-B-64-* removed
mascot-offline.x, then mascot-party.x -F -o mac_fail abort (134) Could not remove ...B-8...: No such file or directory, then MacCheck Failure (exit 1)
tinier-party.x -o mac_fail not run MacCheck Failure, B-64 file removed
binary inputs, -o mac_fail (fails in the input check) MacCheck Failure unchanged
sint multiplication, -o mac_fail MacCheck Failure, Mascot-Secrets-p-* removed unchanged
no fault, on-demand and -F success success

Not changed here: with -F, the key file the online phase actually reads (Player-MAC-Keys-* in the preprocessing directory) is still not removed. See the open question in the issue.

mac_fail_remove() asserted that unlinking the secrets file succeeds.
For Tinier shares the file name was never registered on the share
type that runs the MAC check, so the name was derived from the wrong
type (B-8 instead of the B-64 file written by key generation) and the
file never exists. The same happens with any share type when the MAC
key comes from files without a matching secrets file. The party then
aborts on the assertion instead of reporting the MAC check failure,
and with live preprocessing the actual binary key material is kept.

Register the secrets file name on the Tinier part type as well, and
report a failed unlink without aborting so that mac_fail is always
thrown. This also keeps the unlink when compiled with NDEBUG.
@CLAassistant

CLAassistant commented Nov 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mkskeller
mkskeller merged commit f5f0cd2 into data61:master Nov 20, 2026
3 checks passed
@mkskeller

Copy link
Copy Markdown
Member

Thank you

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.

Assertion failure in mac_fail_remove() after a binary (Tinier) MAC check failure in MASCOT

3 participants