Skip to content

[17.0-stable] Harden 802.1X (PNAC) re-authentication and removal handling - #6987

Merged
eriknordmark merged 7 commits into
lf-edge:17.0-stablefrom
milan-zededa:backport-6929-17.0-stable
Nov 1, 2026
Merged

eriknordmark merged 7 commits into
lf-edge:17.0-stablefrom
milan-zededa:backport-6929-17.0-stable

Conversation

@milan-zededa

@milan-zededa milan-zededa commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #6929

The original PR hardens 802.1X (PNAC) re-authentication and removal handling
in nim: re-authentication on a wired port is now detected through the
wpa_supplicant control socket, an EAPOL-Logoff is sent when the supplicant is
stopped, and the DHCP lease is reacquired when PNAC is removed from a port
(unless the lease already moved to another subnet). It also extends the
TestPNAC evetest with stress cycles. For more details refer to the original PR.

All 7 commits were cherry-picked with -x. Conflicts on 17.0-stable:

  • nim: detect 802.1X re-authentication through the wpa_supplicant control socket:
    wpa_supplicant_test.go does not exist on 17.0-stable, so its 5-line
    deletion was dropped (file stays deleted).
  • nim: reacquire DHCP lease when PNAC is removed from a port: 17.0-stable has
    no dnsCacheClearPending logic in verifyDPC(); only the DHCP-reacquire
    wait was kept.

How to test and validate this PR

Covered by the automated TestPNAC evetest (including the new stress cycles).
Manually: on a port with PNAC enabled, force re-authentication from the switch
(e.g. with a VLAN change) and verify nim updates the PNAC state and reacquires
DHCP; remove PNAC from the port and verify the lease is reacquired.

Changelog notes

Improves handling of 802.1X (PNAC) on wired ports: re-authentication and
authentication failures are now detected reliably, and the DHCP lease is
refreshed when 802.1X is removed from a port or the port moves to another VLAN.

PR Backports

  • 17.0-stable: This PR.
  • 16.0-stable: No, PNAC hardening is not planned for this branch.
  • 14.5-stable: No, PNAC hardening is not planned for this branch.
  • 13.4-stable: No, PNAC hardening is not planned for this branch.

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

For backport PRs (remove it if it's not a backport):

  • I've added a reference link to the original PR
  • PR's title follows the template

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

🤖 Generated with Claude Code

milan-zededa and others added 7 commits October 30, 2026 15:26
Extend TestPNAC with a configurable number of cycles
(EVETEST_PNAC_REAUTH_CYCLE_COUNT, default 3) that exercise 802.1X
more aggressively than a single enrollment and authentication:

- re-initialize the port on the authenticator twice and verify that
  LastAuthTimestamp advances each time and the port keeps an IP from
  the authenticated VLAN
- make the authenticator trust only an unrelated CA and verify that
  the failure is reported and the port gets a pre-auth VLAN IP
- restore the CA and verify that EVE recovers on its own
- disable PNAC and remove the SCEP profile, verify the certificate is
  removed and the port falls back to the pre-auth VLAN, then enroll a
  new certificate with a different key type and hash
- log EVE memory usage after every cycle and fail if it approaches
  the EVE memory limit, so a higher cycle count can expose growth

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit feb1432)
Bumping Hostapd.ReauthGeneration only deauthenticated the stations.
For a wired supplicant that sends no frame at all, so the supplicant
kept considering its port authorized and never re-authenticated,
unlike with a real switch that re-initializes the port and sends a
new EAP-Request/Identity.

After deauthenticating, wait for hostapd to remove each station and
add it back with "hostapd_cli new_sta", which makes hostapd start a
new EAP exchange.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit c96f1ea)
…ol socket

nim learned about the 802.1X state from "wpa_cli -a", which only calls
its action script for CONNECTED and DISCONNECTED. When a wired port
re-authenticates (e.g. after the authenticator re-initializes it),
wpa_supplicant stays in the COMPLETED state and emits neither event.
As a result the PNAC state file was not updated, the reported
LastAuthTimestamp stayed stale and, if the switch had moved the port to
a different VLAN, DHCP was never reacquired. The same happened when
the authenticator rejected the certificate after such a re-init.

Attach to the control socket of wpa_supplicant directly and update the
PNAC state file also on CTRL-EVENT-EAP-SUCCESS and
CTRL-EVENT-EAP-FAILURE. Events are coalesced for a short moment so that
the supplicant state machines have settled before the network monitor
reads the status. The wpa_cli watcher process and its generated script
are no longer needed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit dc0e997)
When PNAC is disabled or reconfigured, nim stops wpa_supplicant by
terminating the process. That does not make the supplicant send an
EAPOL-Logoff frame, so the authenticator keeps treating the port as
authorized and does not move it back to the pre-authentication VLAN.

Ask wpa_supplicant to log off through its control socket before it is
stopped. The event listener is stopped first, so the logoff is not
reported as a change of the authentication state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit 4040141)
When PNAC is removed from a port, the supplicant logs off and the switch
may move the port to a different VLAN, so the lease has to be reacquired
just like after a change of the authentication state. The scheduled
reacquire used to be cancelled whenever the current DPC had PNAC disabled.
Cancel it only if the PNAC configuration of the port differs from the one
at the time of scheduling, or the port has no DHCP client.

Also make DPC verification wait for the first DHCP reacquire of a port
to finish (bounded the same way as for async operations). Otherwise the
connectivity test of a new DPC can run with a lease obtained in the
previous VLAN, fail, and make nim fall back to the previous DPC.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit 146cbcf)
The console was described as unusable by AI agents. It can be driven by
piping short commands into it, and it is the only way in when ssh does
not work because of networking problems, which is when it is most useful.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit 2b91156)
After a PNAC state change, the DHCP client may obtain a lease from the new
VLAN by itself before the first scheduled reacquire runs. Releasing that
lease again caused a short loss of the IP address and of the DNS servers
right after the port was reported as authenticated, which made connections
started at that moment fail.

Cancel the reacquire tracker instead of releasing the lease when the subnet
of the port already differs from the one recorded when the PNAC event was
received.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit 88aefcf)
@milan-zededa
milan-zededa requested a review from rene October 30, 2026 14:58
@milan-zededa milan-zededa added the next-17.0.x-rc PR must be present in the next 17.0.x-lts release label Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.82353% with 84 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.87%. Comparing base (1791e05) to head (ca33d7f).

Files with missing lines Patch % Lines
...illar/dpcreconciler/genericitems/wpa_supplicant.go 0.00% 51 Missing ⚠️
pkg/pillar/dpcreconciler/genericitems/wpa_ctrl.go 82.35% 14 Missing and 7 partials ⚠️
pkg/pillar/dpcmanager/verify.go 0.00% 7 Missing and 1 partial ⚠️
pkg/pillar/dpcmanager/dpcmanager.go 84.61% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           17.0-stable    #6987      +/-   ##
===============================================
+ Coverage        23.24%   23.87%   +0.62%     
===============================================
  Files              516      527      +11     
  Lines            95468    97158    +1690     
===============================================
+ Hits             22193    23197    +1004     
- Misses           71401    72125     +724     
+ Partials          1874     1836      -38     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknordmark
eriknordmark merged commit 5e14586 into lf-edge:17.0-stable Nov 1, 2026
59 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next-17.0.x-rc PR must be present in the next 17.0.x-lts release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants