Skip to content

Agent enroll: a MAC alone no longer vouches for a different machine - #2104

Merged
fog-workflows[bot] merged 1 commit into
dev-branchfrom
fix/enroll-mac-fallback-contradiction
Nov 17, 2026
Merged

fog-workflows[bot] merged 1 commit into
dev-branchfrom
fix/enroll-mac-fallback-contradiction

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Problem

An unregistered machine that carries a MAC registered to host A binds its fog-agent enrollment to host A with reason known-host-no-agent. The forum 18319 case is a USB Ethernet adapter shared between laptops. Within FOG_AGENT_ENROLL_DEPLOY_WINDOW (default 24 hours) of a deploy to A, _autoApproval() approves that request with no admin. So a different laptop can be issued A's agent identity.

The setting's own description limits the shortcut to "an agent presenting that host's firmware identity". The code did not check the firmware.

MachineIdentity::resolve() (the directory-identity enroll path and identity/check) had the same MAC-only resolution.

Fix

Suppose only the MAC found the host, and the reported serial contradicts that host's stored serial. The check is SmbiosIdentity::contradicts() from #2100: the system serial decides when both sides have one, and placeholders never count. Then:

  • Enrollment::_resolve() records identity-conflict against host A. The deploy window never approves a conflict. An admin still can, for a real board swap.
  • MachineIdentity::resolve() returns conflict.

With FOG_HOST_IDENTIFY_SMBIOS set to off, identity is ignored as before.

Verification

  • tests/agent-identity-check.test.php: 51 checks pass.
    • Disabling the enrollment guard fails "enrollment: a contradicted MAC match is a conflict".
    • Disabling the resolver guard fails "resolve() refuses a MAC the serial contradicts".
  • The fake PDO row factory may now return null to answer a SELECT with no row. Without that change, the resolver test could pass on "ambiguous firmware" and never reach the serial check.
  • Both phpstan passes are clean.

Not changed

  • An enroll token still approves any request, a conflict included. A token is an admin's explicit vouch.
  • A host with no inventory row has nothing to contradict, so its MAC binding behaves as before.
  • A request that is already pending at upgrade keeps its stored reason. The deploy window can still approve it on its next poll.

🤖 Generated with Claude Code

An unregistered machine carrying a MAC registered to host A (a USB
Ethernet adapter shared between laptops, forum 18319) bound to host A
as known-host-no-agent. Within FOG_AGENT_ENROLL_DEPLOY_WINDOW of a
deploy to A, that request was approved with no admin, so a different
laptop could be issued A's agent identity. The setting promises the
shortcut only for an agent presenting A's firmware identity.

When only the MAC found the host and the reported serial contradicts
the host's stored one (SmbiosIdentity::contradicts()), enrollment now
records an identity-conflict. The deploy window never approves a
conflict; an admin still can, for a real board swap. The directory
identity resolver returns conflict for the same case.

The fake PDO row factory may now return null to answer a SELECT with no
row, so the resolver test reaches the serial check instead of failing
earlier as ambiguous firmware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 17, 2026 15:24
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into dev-branch with commit cbdca0b Nov 17, 2026
12 checks passed
@fog-workflows
fog-workflows Bot deleted the fix/enroll-mac-fallback-contradiction branch November 17, 2026 15:34
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