Skip to content

add SRP user authentication method#2876

Open
rdmark wants to merge 1 commit intomainfrom
2842-reverse-engineer-the-srp-uam
Open

add SRP user authentication method#2876
rdmark wants to merge 1 commit intomainfrom
2842-reverse-engineer-the-srp-uam

Conversation

@rdmark
Copy link
Copy Markdown
Member

@rdmark rdmark commented Apr 10, 2026

Implement the SRP (Secure Remote Password) UAM for AFP, as used by Apple Time Capsule.
The protocol uses SRP-6a with SHA-1, MGF1 KDF, and RFC 5054 group #2 (1536-bit).

afppasswd is modified to operate on SRP storage file by default, which stores per-user salts and verifiers, while retaining the legacy RandNum functionality activated with the -r flag.

An additional breaking change is that afppasswd -a now takes username as argument rather than previous positional username arugment.

The containers now use SRP for authentication by default.

@rdmark rdmark linked an issue Apr 10, 2026 that may be closed by this pull request
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from cfe7560 to 120a4b7 Compare April 10, 2026 08:31
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from 120a4b7 to 5f710be Compare April 10, 2026 09:35
@rdmark rdmark marked this pull request as ready for review April 10, 2026 10:40
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 10, 2026

🤖 Augment PR Summary

Summary: This PR adds SRP (Secure Remote Password) authentication support for AFP, matching the SRP-6a/SHA-1 behavior used by Apple Time Capsule/macOS.

Changes:

  • Adds a new UAM plugin uams_srp.so implementing the SRP handshake and mutual proofs (M1/M2).
  • Introduces a new global config option srp passwd file and plumbs it through afpd’s UAM option interface.
  • Extends afppasswd to manage an SRP verifier store by default (afppasswd.srp), keeping legacy RandNum behavior behind -r.
  • Updates build definitions (Meson) to define the default SRP verifier path and to build/install the SRP UAM.
  • Adjusts Docker and macOS spectest setup to initialize both RandNum and SRP credential stores.
  • Updates docs (afppasswd(1), afp.conf(5), Authentication manual) and the Webmin module to expose the new SRP password file path.

Technical Notes: SRP verifier file format is username:hex_salt:hex_verifier using RFC 5054 group #2 (1536-bit) with SHA-1 and MGF1-derived session keys.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 5 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from 5f710be to f6920bb Compare April 10, 2026 12:06
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from f6920bb to 4d13f7c Compare April 10, 2026 12:17
@rdmark rdmark requested a review from andylemin April 10, 2026 12:36
@rdmark rdmark marked this pull request as draft April 10, 2026 13:32
@rdmark
Copy link
Copy Markdown
Member Author

rdmark commented Apr 10, 2026

while SRP auth works afpfs-ng -> netatalk, it doesn't work macOS -> netatalk yet so we have a bug somewhere

false alarm, it works when you use the correct password 😅

@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from 4d13f7c to c051bce Compare April 10, 2026 13:58
@rdmark rdmark marked this pull request as ready for review April 10, 2026 13:58
Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from c051bce to fb19d0b Compare April 10, 2026 17:02
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from fb19d0b to d17ed27 Compare April 10, 2026 17:22
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from d17ed27 to b4e4073 Compare April 10, 2026 17:34
@NJRoadfan
Copy link
Copy Markdown
Contributor

Tested and working here.

@andylemin
Copy link
Copy Markdown
Contributor

Very cool! Well done indeed.. I'll do a proper code review in the next couple of days

Implement the SRP (Secure Remote Password) UAM for AFP,
as used by Apple Time Capsule.
The protocol uses SRP-6a with SHA-1,
MGF1 KDF, and RFC 5054 group #2 (1536-bit).

afppasswd is modified to operate on SRP storage file by default,
which stores per-user salts and verifiers,
while retaining the legacy RandNum functionality
activated with the -r flag.

An additional breaking change is that afppasswd -a now takes username
as argument rather than previous positional username arugment.

The containers now use SRP for authentication by default.
@rdmark rdmark force-pushed the 2842-reverse-engineer-the-srp-uam branch from b4e4073 to 0849baa Compare April 12, 2026 06:29
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Spectest (AFP 3.4) - Flamegraph (AFP_ASSERT active)

Commit: 0849baa8a60f6078eab5808a8cb5be131c11ebb1
Profiling: On-CPU sampling @ 1009 Hz (prime), DWARF call-graph, x86_64
Build: debugoptimized (-O2 -g -fno-omit-frame-pointer)
Total Runtime: 66s, Netatalk Code-time: 7.3%,
Stacks: 1119, SVG size: 800K

🔥 Open interactive Flamegraph (SVG)

Flamegraph preview

📥 Download from artifacts →

🔝 Top 10 leaf functions
Function Samples
_raw_spin_unlock_irqrestore 290386440
do_syscall_64 112983120
__cp_end 84241800
dircache_remove_children 69375600
srso_alias_safe_ret 39643200
dircache_process_deferred_chain 26759160
finish_task_switch.isra.0 24777000
__syscall_cp_c 22794840
find_get_block_common 17839440
x64_sys_call 16848360

@andylemin
Copy link
Copy Markdown
Contributor

QR review shows this is a high quality PR 🙂 This looks to be a well-engineered implementation of the SRP-6a protocol.
The cryptographic primitives are correct, sensitive data is properly cleaned up, the code follows established codebase patterns, error handling is thorough, and the documentation is comprehensive. RFC 5054 N prime constants look good.

Minor comments;
Remove unused SRP_AUTH_FAILURE macro if not planned for future use.
Consider constant-time comparison for M1 verification (memcmp → custom ct_memcmp) as a defense-in-depth measure.

LGTM - Impressive work! 🚀

@rdmark
Copy link
Copy Markdown
Member Author

rdmark commented Apr 14, 2026

@andylemin thanks for the review!

Remove unused SRP_AUTH_FAILURE macro if not planned for future use.

I have been going back and forth about this; SRP_AUTH_FAILURE (-6754) is what I observed the Time Capsule AFP server returned when the M1 proof is invalid (both incorrect crypto as well as incorrect user password), however this error code is not defined in he AFP spec. Right now I'm using AFPERR_NOTAUTH (-5023) consistently to match the other UAMs which the macOS AFP client doesn't seem to mind.

Do you have any advice here, whether to emulate Time Capsule fully or attempt to adhere to the AFP spec where appropriate?

@andylemin
Copy link
Copy Markdown
Contributor

@andylemin thanks for the review!

Remove unused SRP_AUTH_FAILURE macro if not planned for future use.

I have been going back and forth about this; SRP_AUTH_FAILURE (-6754) is what I observed the Time Capsule AFP server returned when the M1 proof is invalid (both incorrect crypto as well as incorrect user password), however this error code is not defined in he AFP spec. Right now I'm using AFPERR_NOTAUTH (-5023) consistently to match the other UAMs which the macOS AFP client doesn't seem to mind.

Do you have any advice here, whether to emulate Time Capsule fully or attempt to adhere to the AFP spec where appropriate?

I think we have seen enough examples of Apple not complying with the AFP spec themselves, so I think we should go with what is required for Time Capsule and just acknowledge any spec violations?

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.

reverse engineer the SRP UAM

3 participants