Skip to content

authentication manager feature addition#270

Open
JacobBarthelmeh wants to merge 53 commits intowolfSSL:mainfrom
JacobBarthelmeh:auth_manager
Open

authentication manager feature addition#270
JacobBarthelmeh wants to merge 53 commits intowolfSSL:mainfrom
JacobBarthelmeh:auth_manager

Conversation

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor

@JacobBarthelmeh JacobBarthelmeh commented Jan 16, 2026

The authentication manager feature adds support for a user login and checking a users permissions for performing a group+action. The API was designed with PKCS11 in mind.

Some things of note:

  • I added a callback function framework for checking authorization of key use based on key ID and user permissions but did not tie in that check yet. I would like to tie that in later when/if needed. This currently checks for authorization of user for a group/action that they can do. Which ties a user ID to crypto actions done.
  • The user list in port/posix/posix_auth.c is a simple list not yet in NVM. This initial simplicity is deliberate.
  • There is a TODO listed for logging of authentication events. Login failures, success, crypto actions should have logging additions in the future.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a comprehensive authentication and authorization manager to wolfHSM, enabling user management, login/logout functionality, and permission-based access control for HSM operations.

Changes:

  • New authentication manager with PIN and certificate-based authentication support
  • Authorization system with group and action-level permission checks
  • User management APIs for adding, deleting, and modifying users and their credentials
  • Complete client and server implementation with message translation support

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
wolfhsm/wh_auth.h Core auth manager types, structures, and API definitions
wolfhsm/wh_message_auth.h Message structures and translation functions for auth operations
wolfhsm/wh_server_auth.h Server-side auth request handler declaration
wolfhsm/wh_client.h Client-side auth API function declarations
wolfhsm/wh_server.h Server context updated with auth context pointer
wolfhsm/wh_message.h New auth message group and action enums
wolfhsm/wh_error.h New auth-specific error codes
src/wh_auth.c Core auth manager implementation with callback wrappers
src/wh_message_auth.c Message translation implementations for auth messages
src/wh_server_auth.c Server-side request handler for auth operations
src/wh_client_auth.c Client-side auth API implementations
src/wh_server.c Server integration with authorization checks
src/wh_client.c Minor formatting fixes
port/posix/posix_auth.h POSIX auth backend declarations
port/posix/posix_auth.c POSIX auth backend implementation with in-memory user storage
test/wh_test_auth.h Auth test suite declarations
test/wh_test_auth.c Comprehensive auth test suite implementation
test/wh_test.c Test integration for auth tests
examples/posix/wh_posix_server/* Server configuration with auth context setup
examples/demo/client/wh_demo_client_all.c Demo integration for auth

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfhsm/wh_client.h Outdated
Comment thread test/wh_test_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Comment thread wolfhsm/wh_message_auth.h Outdated
Comment thread wolfhsm/wh_client.h Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread port/posix/posix_auth.c Outdated
Comment thread src/wh_message_auth.c
Comment thread port/posix/posix_auth.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/demo/client/wh_demo_client_auth.c Outdated
Comment thread examples/demo/client/wh_demo_client_auth.c Outdated
@bigbrett
Copy link
Copy Markdown
Contributor

@JacobBarthelmeh merge conflicts

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor Author

Force pushed to resolve merge conflict.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 17 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wh_auth_base.c
Comment thread src/wh_auth.c Outdated
Comment thread src/wh_server_auth.c Outdated
Comment thread test/wh_test_clientserver.c
Comment thread src/wh_client_auth.c Outdated
Comment thread src/wh_server_auth.c
Comment thread src/wh_message_auth.c Outdated
Comment thread src/wh_client_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Comment thread port/posix/posix_auth.c Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 16:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 43 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfhsm/wh_server.h
Comment thread src/wh_client_auth.c
Comment thread src/wh_utils.c
Comment thread src/wh_auth_base.c Outdated
Comment thread src/wh_auth.c
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #270

Scan targets checked: wolfhsm-consttime, wolfhsm-core-bugs, wolfhsm-defaults, wolfhsm-mutation, wolfhsm-proptest, wolfhsm-src, wolfhsm-zeroize

Findings: 7
7 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/wh_auth_base.c
Comment thread src/wh_auth_base.c
Comment thread src/wh_auth_base.c
Comment thread src/wh_auth.c
Comment thread src/wh_server.c
Comment thread src/wh_auth_base.c
Comment thread src/wh_auth_base.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 43 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

wolfhsm/wh_auth.h:1

  • The comment says this macro enables the group and only the given action bit, but the implementation ORs the bit into the existing mask (it does not clear other action bits). Either update the comment to match behavior ("enables the given action bit") or change the macro to clear all action words for the group before setting the single bit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wh_server.c
Comment thread src/wh_server_auth.c
Comment thread src/wh_client_auth.c
Comment thread src/wh_auth_base.c
Comment thread src/wh_auth_base.c Outdated
Comment thread test/wh_test_common.h
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wh_server.c
Comment thread wolfhsm/wh_message_auth.h
Copy link
Copy Markdown
Contributor

@bigbrett bigbrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, one blocking bugfix needed, as well as a documentation update to tag this feature as experimental. I will post a list of the other issues found in a subsequent review that can then be addressed with follow-up PRs

Comment thread src/wh_auth_base.c
Comment on lines +291 to +294
/* do not allow duplicate users with same name */
if (strcmp(users[i].user.username, username) == 0) {
return WH_ERROR_BADARGS;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uniqueness loop in UserAdd breaks at the first empty slot instead of scanning the whole array. UserDelete zeroes slots in place without compacting, so any delete creates a gap that blinds the check to everything past it.

The attack (identity confusion / lockout):

  1. State: [0]=bob, [1]=admin.
  2. Admin deletes bob → [0]=empty, [1]=admin.
  3. Attacker with USER_ADD perm calls UserAdd(username="admin", ...) with their own PIN.
  4. Loop breaks at slot 0 (empty), never scans slot 1 → duplicate admin is inserted.
  5. FindUser("admin") returns the first match → always the impostor.
  6. Real admin's login fails (PIN doesn't match impostor's hash) = locked out. Attacker logs in as "admin" at their own (non-admin) permissions = identity confusion.

Key insight: The attacker doesn't gain admin rights — they gain the name "admin", which is enough to shadow the real account in every name-based lookup.

Fix: Two-pass the loop — scan all slots for duplicates, then find a free slot. Or compact the array on delete.

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.

6 participants