Skip to content

Replace bcrypt challenge auth with direct password comparison - #9358

Merged
Alkarex merged 29 commits into
FreshRSS:edgefrom
Inverle:remove-bcrypt-challenge-auth
Oct 30, 2026
Merged

Alkarex merged 29 commits into
FreshRSS:edgefrom
Inverle:remove-bcrypt-challenge-auth

Conversation

@Inverle

@Inverle Inverle commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Closes #2428

Highlights:

  • Replaced the bcrypt challenge authentication flow with direct password comparison against the bcrypt hash stored in the user configuration.
    • Removed the bcrypt.js dependency, so authentication no longer depends on JavaScript.
    • Removed the nonce and challenge mechanism and the nonce endpoint from the javascript controller.
    • Removed the JavaScript and HTML code used for the previous authentication flow.
    • Removed the <noscript> blocks that were only needed for the previous authentication flow.
  • Updated FreshRSS_FormAuth::checkCredentials() to accept the username, stored bcrypt hash, and plain-text password directly.
    • The stored password hash must still use the expected bcrypt format.
    • Empty or whitespace-only passwords are rejected even if the hash would otherwise match.
    • The bcrypt 72-byte limit is enforced during normal authentication.
    • Existing bcrypt passwords are handled correctly when the 72-byte limit cuts through a UTF-8 character.
    • Password input is no longer trimmed before authentication or password changes. Leading and trailing whitespace is therefore kept as part of the password.
  • Added FreshRSS_FormAuth::passwordRequirementsMet() to replace FreshRSS_password_Util::check().
    • New passwords must be between 7 and 72 bytes by default.
    • The minimum length check can be disabled where needed.
    • Password requirements are now checked server-side for all password creation and update paths.
  • Added client-side byte-length validation for password fields using TextEncoder and data-max-bytes.
    • This gives better feedback for UTF-8 passwords.
    • Server-side validation remains authoritative.
  • Updated password handling in authentication, re-authentication, self-deletion, user creation, and user update paths so passwords are not trimmed automatically.
  • Added FormAuthTest to cover:
    • password length limits in bytes
    • UTF-8 passwords around the 72-byte limit
    • bcrypt truncation behavior during authentication
    • malformed and non-bcrypt hashes
    • empty passwords
    • authentication failures and log messages
  • Removed bcrypt.js from the documented dependencies and updated the authentication documentation.
  • Updated the installation and authentication views and JavaScript to match the new password handling.

This simplifies the authentication flow, removes the client-side bcrypt challenge, makes password validation consistent between the client and server, and adds more test coverage while keeping compatibility with existing bcrypt password hashes.

Because the password is now sent directly to the server instead of being processed by bcrypt.js, deployments should use HTTPS. Documentation for HTTPS setup can be handled separately.

Prerequisite: #9362 should be merged before this PR.

@Inverle Inverle added this to the 1.31.0 milestone Sep 26, 2026
@Inverle Inverle added Security 🛡️ System care Everything related to system care labels Sep 26, 2026
@Inverle
Inverle force-pushed the remove-bcrypt-challenge-auth branch from 95ade11 to 690c7c1 Compare September 26, 2026 21:50

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fwiw I think the idea is that the bcrypt encryption protects against getting the password almost by accident (read: effortlessly, completely untargeted) in logs or some such, not that it's some kind of brilliant protection.

In any case, nothing jumps out at me in the PR.

Comment thread app/Models/FormAuth.php Resolved
@Inverle

Inverle commented Sep 27, 2026

Copy link
Copy Markdown
Member Author

#9362 needs to be merged before this PR

@Inverle Inverle added the Minz Pull requests that update Minz code label Sep 30, 2026
@Inverle

Inverle commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

I improved the tests a bit.

@Inverle

Inverle commented Oct 4, 2026 •

Copy link
Copy Markdown
Member Author

Will also remove maxlength and go back to pattern, now that data-max-bytes is used, maybe. (for better UX again)

done

@Inverle

Inverle commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

Somehow link checker didn't fail this time. I guess Gentoo wiki responded with 200 once, since it's still down.

@Alkarex

Alkarex commented Oct 25, 2026

Copy link
Copy Markdown
Member

Let's go for it, but we need to warn a bit in advance.
HTTPS cannot be expected in a number of scenarios, including local networks. There is also the case of tunnel services or proxy services doing the HTTPS part, and those third-party services will suddenly see the password in plain text. This is especially bad for users reusing their passwords (which is of course a bad practice). And I am probably forgetting other cases as well.

@Inverle

Inverle commented Oct 25, 2026 •

Copy link
Copy Markdown
Member Author

Is there anything I should change in the PR?

@Inverle

Inverle commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

I forgot about 50c36b8, is it still ok?

@Alkarex

Alkarex commented Oct 26, 2026

Copy link
Copy Markdown
Member

header('HTTP/1.1 500 Internal Server Error');
Minz_Request::setBadNotification(_t('install.session.nok'));
Minz_Request::forward(['c' => 'auth', 'a' => 'login'], false);
Minz_Request::forward(['c' => 'auth', 'a' => 'login'], redirect: true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is still sending a proper HTTP 500, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, because redirects only work with 3xx status codes.

But at the same time a redirect is needed here currently, due to a Minz bug that is yet to be addressed: #8535 (we don't want to leak passwordPlain in GET params)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I forgot about this though

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread app/i18n/fr/user.php Resolved
@Alkarex
Alkarex merged commit 76e8993 into FreshRSS:edge Oct 30, 2026
4 checks passed
@Inverle
Inverle deleted the remove-bcrypt-challenge-auth branch October 30, 2026 21:52
Comment on lines -172 to -180
$challenge = Minz_Request::paramString('challenge');
$newPasswordPlain = '';
if ($challenge !== '') {
$passwordPlain = Minz_Request::paramString('passwordPlain', plaintext: true, trim: false);
$newPasswordPlain = Minz_Request::paramString('newPasswordPlain', plaintext: true, trim: false);
$confirmPasswordPlain = Minz_Request::paramString('confirmPasswordPlain', plaintext: true, trim: false);
if ($passwordPlain !== '') {
$username = Minz_User::name();
$nonce = Minz_Session::paramString('nonce');
Minz_Session::_param('nonce', false); // One-time: consume the challenge so it cannot be replayed.

$newPasswordPlain = Minz_Request::paramString('newPasswordPlain', plaintext: true);
$confirmPasswordPlain = Minz_Request::paramString('confirmPasswordPlain', plaintext: true);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Alkarex added a commit that referenced this pull request Nov 10, 2026
* Fix current password requirement during password changes

Regression from #9358 (follow-up, PR not present in a stable/versioned release)

Fix [GHSA-5vxm-62pg-frff](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5vxm-62pg-frff)

* Remove stale client side bcrypt comment from passwordUtil

* docs: PHP 8.1 is no longer supported

* Minor typographic preference

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Alkarex pushed a commit that referenced this pull request Nov 15, 2026
Regression from #9358 (PR not present in current release, stopped sending 403 on failed logins).

This PR fixes the Minz bug mentioned in #9358 (comment) which occurred with `redirect: false` redirects.

But it also takes a different approach for redirecting, by using HTML instead of the `Location` header (to address one additional issue with a resubmit prompt appearing when refreshing the login page after a failed login).

403 is now returned during failed reauthentication as well.
@SjoerdV

SjoerdV commented Nov 23, 2026 •

Copy link
Copy Markdown

Fwiw I think the idea is that the bcrypt encryption protects against getting the password almost by accident (read: effortlessly, completely untargeted) in logs or some such, not that it's some kind of brilliant protection.

In any case, nothing jumps out at me in the PR.

So if I understand this correctly this will make the password visible on any reverse proxy with ssl/tls termination, which is commonly hosted in a dmz (ie. low trust), which is a very common scenario?

So effectively this simplification to the codebase made the product less secure?

@Frenzie

Frenzie commented Nov 23, 2026

Copy link
Copy Markdown
Member

Yes, that means there's less passive observer protection, though whether it actually makes it less secure is debatable. Anything that terminates TLS like that could also simply replace the HTML with whatever it wants thus undoing the client-side bcrypt.

@SjoerdV

SjoerdV commented Nov 23, 2026 •

Copy link
Copy Markdown

Yes, that means there's less passive observer protection, though whether it actually makes it less secure is debatable. Anything that terminates TLS like that could also simply replace the HTML with whatever it wants thus undoing the client-side bcrypt.

Sure, but if the low trust dmz rp gets hacked (very likely in this day and age!) then plain text password sniffing is just easy peasy, I would prefer they just get hashes instead. You can learn a lot from a user's password imho...

At least the password is not in a url query parameter but in POST request (I hope 😉 ?)

I personally think this pull is a mistake. Following Nextcloud and using Argon2id with Argon2i & bcrypt fallbacks as authentication password hashing method would be my preference.
On a positive note: re-implementing password hashing "the right way™️" now the codebase is cleaned up, is a lot easier.

@Frenzie

Frenzie commented Nov 23, 2026

Copy link
Copy Markdown
Member

The cleanup was mostly just removing it. I don't think adding it back would look substantially different. Either way I'm neutral on the matter.

@SjoerdV

SjoerdV commented Nov 23, 2026

Copy link
Copy Markdown

The cleanup was mostly just removing it. I don't think adding it back would look substantially different. Either way I'm neutral on the matter.

Instead of just adding it back it would probably make more sense to upgrade to a more modern approach, with some brute-force GPU hacking protection built in. Also Nextcloud uses it, so couldn't be all bad. Maybe this is of help (not mine, but gave me some insight): transitioning to argon2id from bcrypt: https://gyaando.com/php-password-hash-bcrypt-vs-argon2id/

@Frenzie

Frenzie commented Nov 24, 2026

Copy link
Copy Markdown
Member

Maybe, but that doesn't affect what I said. ;-)

@SjoerdV

SjoerdV commented Nov 24, 2026

Copy link
Copy Markdown

Maybe, but that doesn't affect what I said. ;-)

Ok so there probably wont be a feature request adding (more modern) password hashing support back in any time soon. More of a ‘spare time’ kind of thing, I guess.

But can we just roll back this pull then?

I don’t really understand what was ‘won’ by removing something that does work in obfuscating ‘real’ user passwords on low trust environments, so nothing is ‘won’ and “authentication uses no javascript anymore” is a very bad argument as everything after login DOES use javascript… so this is just weird and AM really passionate of retaining at least this feature.

So everything short of ‘pretty please’, but PRETTY PLEASE 🙏 ✌️😉

@Frenzie

Frenzie commented Nov 24, 2026

Copy link
Copy Markdown
Member

The underlying motivation for @Inverle was various things like #8320 and #8343.

@Alkarex

Alkarex commented Nov 24, 2026

Copy link
Copy Markdown
Member

Communication asking for comments: https://framapiaf.org/@freshrss/117509044759169110

@SjoerdV

SjoerdV commented Nov 24, 2026 •

Copy link
Copy Markdown

The underlying motivation for @Inverle was various things like #8320 and #8343.

Yeah well for me its just

  • DEVS are probably running single server instances?
  • Somebody needed a project?
  • Lets make our product less secure OOTB because of requiring certs across the chain
  • Lets facilitate accidental plain text password logging across the chain
  • Lets give hackers immediate ‘no effort’ access to plain text passwords, even in low trust setups
  • Security by default AND by design? What kind of principles are those?

I know its FOSS, sure, but the negatives just clearly outweigh the positives imho and removing a thing that does at least ‘something’ for security/privacy is just a weird action.

In my opinion FOSS should be about always improving not removing; willy-nilly and “Always take your time, for any change is your baby”

just my 2 cents, because I care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Important 🔥 Minz Pull requests that update Minz code Security 🛡️ System care Everything related to system care

Projects

None yet

Development

Successfully merging this pull request may close these issues.

From Authentication Hashes

4 participants