Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max length of radius secret in radcli #103

Open
DimitriPapadopoulos opened this issue May 1, 2024 · 12 comments
Open

max length of radius secret in radcli #103

DimitriPapadopoulos opened this issue May 1, 2024 · 12 comments

Comments

@DimitriPapadopoulos
Copy link
Contributor

DimitriPapadopoulos commented May 1, 2024

See openconnect/recipes !28:

[...] discovered radius authentication is not working because authentik-radius outpos has shared secret 128 characters in length while radcli silently limits length to be less than 96 characters.

This appears to be the source of this limitation:

#define MAX_SECRET_LENGTH (6 * 16) /* MUST be multiple of 16 */

Would it make sense to increase it to 8 * 16?

@nmav
Copy link
Contributor

nmav commented May 5, 2024

The question would be why the existing limit is not enough? There always be some use for an extremely large number of characters, but the default values do not necessarily need to cope for that. To change the default the best would be to understand the reason to do so.

@DimitriPapadopoulos
Copy link
Contributor Author

The "reason" is:

authentik-radius outpos has shared secret 128 characters in length

The max length is probably buried somewhere in https://github.com/goauthentik/authentik/tree/main/authentik/providers/radius or even higher up under https://github.com/goauthentik/authentik/tree/main.

@nmav
Copy link
Contributor

nmav commented May 5, 2024

So it generates a 128-character secret by default or it has a max length of 128-characters?

@DimitriPapadopoulos
Copy link
Contributor Author

It's hard to infer from the source code. I'll ask the end-user...

@DimitriPapadopoulos
Copy link
Contributor Author

When authenticating using radtest from freeradius, with 1234 as the password, the authentik radius server sends this JSON message internally:

[Path with value: /password:1234]
[Member with value: password:1234]
String value: 1234
Key: password
[Path: /password]

When authenticating using radtest from ocserv, again with 1234 as the password, the authentik radius server sends that JSON message:

[Path with value: /password:YS\ufffd\ufffd\u0007ag\ufffdag\ufffdiS\ufffd\ufffd\ufffd\ufffd\u001e\ufffd]
[Member with value: password:YS\ufffd\ufffd\u0007ag\ufffdag\ufffdiS\ufffd\ufffd\ufffd\ufffd\u001e\ufffd]
String value: YS\ufffd\ufffd\u0007ag\ufffdag\ufffdiS\ufffd\ufffd\ufffd\ufffd\u001e\ufffd
Key: password
[Path: /password]

Do you have an clue where this difference come from? Could ocserv be hashing the 1234 password to something starting with YS?

@corpix
Copy link

corpix commented May 8, 2024

@DimitriPapadopoulos I am not an expert in authentik, but it looks like secret is generated during radius outpost setup in authentik web interface

Not sure why it is 128, I've read the User-Password section of the RFC2865, it is not very clear for me, but I don't think there is an upper limit on the password length.
I have also gave a quick grep on freeradius sources and haven't found any limits for password length.

I think it may be a good idea to ask @kensternberg-authentik or @BeryJu (they have touched the authentik radius wizard code corresponding to git blame 🙂 ) why 128 was chosen.

@DimitriPapadopoulos
Copy link
Contributor Author

Thank you so much for the links. They are not crystal clear to me either, but RFC2865 does say:

The String field is between 16 and 128 octets long, inclusive.

@BeryJu
Copy link

BeryJu commented May 8, 2024

I honestly don't remember why the default secret length was set to 128, but it has been that value from the start: goauthentik/authentik@3f5effb

@DimitriPapadopoulos
Copy link
Contributor Author

However, I am not an expert of Radius, and still fail to understand how the following relate and interact:

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented May 8, 2024

The shared secret should be at least 16 octets:

The secret (password shared between the client and the RADIUS server) SHOULD be at least as large and unguessable as a well-chosen password. It is preferred that the secret be at least 16 octets.

A Google search came up with empirical information on upper limits:

A maximal length of 256 would cover a majority of commercial RADIUS servers, would be compatible with FreeRADIUS, and should cover most use cases in practice.

@nmav
Copy link
Contributor

nmav commented May 12, 2024

The shared secret is the secret between ocserv and radius server.

@DimitriPapadopoulos
Copy link
Contributor Author

Yes, it took me some time, but I eventually sorted it out 😄

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 a pull request may close this issue.

4 participants