Skip to content

bootstrap: allow to give password from a file #1218

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

ibizaman
Copy link
Contributor

@ibizaman ibizaman commented Jul 16, 2025

In the bootstrap script, instead of embedding the password in the config file directly, allow to pass a path to a file which contains the password.

This was tested in a NixOS draft PR NixOS/nixpkgs#425923.

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.57%. Comparing base (f8cd7ad) to head (b5cd8c2).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1218      +/-   ##
==========================================
- Coverage   86.92%   86.57%   -0.36%     
==========================================
  Files          64       64              
  Lines       12628    11859     -769     
==========================================
- Hits        10977    10267     -710     
+ Misses       1651     1592      -59     

see 52 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nitnelave nitnelave merged commit 78337bc into lldap:main Jul 16, 2025
17 checks passed
@ibizaman ibizaman deleted the bootstrap_file branch July 16, 2025 22:00
@ibizaman
Copy link
Contributor Author

Thanks @nitnelave for the very fast review and merge :)

@nitnelave
Copy link
Member

@ibizaman you caught me at an extremely lucky moment, these days I usually only review PRs every few days. You just happened to send this while I was reviewing something else!

@ibizaman
Copy link
Contributor Author

Luck is always part of it. Thanks nonetheless :)

declare "$field"="$(printf '%s' "$user_config" | jq --raw-output --arg field "$field" '.[$field]')"
done
printf -- '\n--- %s ---\n' "$id"

create_update_user "$id" "$email" "$displayName" "$firstName" "$lastName" "$avatar_file" "$avatar_url" "$gravatar_avatar" "$weserv_avatar"
redundant_users="$(printf '%s' "$redundant_users" | jq --compact-output --arg id "$id" '. - [$id]')"

if [[ "$password" != 'null' ]] && [[ "$password" != '""' ]]; then
if [[ "$password_file" != 'null' ]] && [[ "$password_file" != '""' ]]; then
"$LLDAP_SET_PASSWORD_PATH" --base-url "$LLDAP_URL" --token "$TOKEN" --username "$id" --password "$(cat $password_file)"

Choose a reason for hiding this comment

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

This looks like it's leaking the password in process listings (which are visible to all processes). Adding a --password-file option to $LLDAP_SET_PASSWORD_PATH, to read the password directly from the file, should fix that.

Copy link
Member

Choose a reason for hiding this comment

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

Why not put it in the env instead, then?

Choose a reason for hiding this comment

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

What feature does that bring? (I'm not familiar with the code, so not sure why you'd want that.) I would avoid secrets in env vars if possible, to reduce risk of leakage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this because I wanted to avoid to embed the password in the config file directly. I wanted the password to be a reference to a file instead.

This comes from wanting to generate the config file and embedding the passwords at generation time leaks the passwords in other parts of the system.

I’m not sure I follow what your proposed fix would be, sorry.

Copy link
Member

Choose a reason for hiding this comment

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

If we have an env var, we can write PASSWORD=$(cat password_file) set_password --user ...

That's simpler and more flexible

Copy link
Contributor Author

@ibizaman ibizaman Jul 21, 2025

Choose a reason for hiding this comment

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

Oh I see what you mean @bjornfor. You mean having the binary itself read the file. I’ll create a PR to do that. It makes much more sense indeed.

Copy link
Member

Choose a reason for hiding this comment

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

Of the two, I'd prefer the env solution, unless you have compelling arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No arguments. The only thing is the comment above about avoiding leakage. I can do either.

Copy link
Member

Choose a reason for hiding this comment

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

I'd need a more specific attack scenario than "avoid leakage". Sure, if you set it in your global env and start other processes they'll see it, but that's not what's proposed here

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