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

users: Avoid reading /etc/shadow #19751

Merged
merged 7 commits into from
Dec 18, 2023
Merged

Conversation

martinpitt
Copy link
Member

The hashed passwords is sensitive data, and it gets copied around in the
browser a lot. This isn't a data leak or security issue, as a malicious
page already has the privilege to read it by itself at any time, and
browsers isolate websites pretty well. However, let's be careful.

We only need /etc/shadow for two reasons:

  • Determine if an account is locked. Let's drop the file format
    assumption and use passwd -S, just as the details page already
    does. Use get_locked() from utils.js, and rework the code to get
    along with it being async.

  • Watch the file to get notified about account changes (locked, expiry,
    etc.). But we only need the event, not the actual data. So install a
    simple no-read file watch for this.

Also avoid reading utmp, as we don't look at its contents.

Thanks to @jeepingben for the suggestion!

@martinpitt
Copy link
Member Author

@allisonkarlitskaya what we talked about yesterday. My hunch is that this is too JSX-y for you, and the solution is just what we talked about. But just in case you want to have a look 😉

jelly
jelly previously approved these changes Dec 15, 2023
Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Thanks!

@jelly
Copy link
Member

jelly commented Dec 15, 2023

Code looks good, but I can't tell if the failing tests are flakes or not.

@martinpitt
Copy link
Member Author

martinpitt commented Dec 17, 2023

They are unrelated flakes, but as always their severity depends on the "3x affected" dynamics. The TestPages tracer message is pretty stubborn, it already happened here and here. I'll just add a commit here to fix it, it's trivial to do.

The arch 3x affected failures need some more work. I'll have a first look.

The test quickly iterates through a lot of languages. This starts/stops
tracer in quick succession, before it can finish. This commonly causes
`internal-error` messages (with translated error descriptions), ignore
them.
Avoid unnecessary function wrapper and use `?.`
That bug is still alive and well after 11 years, so stop claiming it is
fixed.
Split them into the usual "third party" - "our lib" - "page local"
categories.
We are going to use it from the main accounts page as well.
The hashed passwords is sensitive data, and it gets copied around in the
browser a lot. This isn't a data leak or security issue, as a malicious
page already has the privilege to read it by itself at any time, and
browsers isolate websites pretty well. However, let's be careful.

We only need /etc/shadow for two reasons:

 - Determine if an account is locked. Let's drop the file format
   assumption and use `passwd -S`, just as the details page already
   does. Use `get_locked()` from utils.js, and rework the code to get
   along with it being async.

 - Watch the file to get notified about account changes (locked, expiry,
   etc.). But we only need the event, not the actual data. So install a
   simple no-read file watch for this.

Also avoid reading utmp, as we don't look at its contents.

Thanks to @jeepingben for the suggestion!
handleShadow.watch(() => getLogins().then(setDetails), { read: false });

return [handleUtmp, handleShadow];
}, [], null, handles => handles.forEach(handle => handle.close()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

@martinpitt martinpitt merged commit ebdf8da into cockpit-project:main Dec 18, 2023
89 of 91 checks passed
@martinpitt martinpitt deleted the shadow branch December 18, 2023 11:16
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.

3 participants