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

Prevent hash error bcrypt.ErrPasswordTooLong for passwords > 72 bytes in length #397

Merged
merged 5 commits into from
Apr 12, 2023

Conversation

bendbennett
Copy link
Contributor

@bendbennett bendbennett commented Apr 12, 2023

Closes: #396

This PR replicates the behaviour of the bcrypt package in versions of golang.org/x/crypto prior to v0.5.0.

@bendbennett bendbennett requested a review from a team as a code owner April 12, 2023 12:20
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

lgtm 👍🏻, can we also add a note about this behavior to the description of the output bcrypt_hash, so it shows in the docs.

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Given the prior behavior and current, more unfortunate regression behavior, this looks good to me.

Comment on lines 542 to 543
// This is to preserve backwards compatibility and will be removed in
// a subsequent version of the provider.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the plan to validate password length to a maximum of 72 bytes in a future version or should this comment be removed?

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 was thinking in the next major version release we could generate an error if the password length exceeds 72 bytes. If that sounds ok, I'll create a follow-up issue and link it in the code comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please feel free to raise a proposal, however I'm a little worried that may be an unpopular proposal just to appease a specific hashing algorithm behavior that not all affected practitioners (anyone generating long passwords) may need from the resource. I think noting the limitation in that hash description will either be good enough for the purposes of this provider or another proposal could be made to move that hashing algorithm to another provider (potentially in a provider-defined function once available) and drop the "problematic" attribute as out of scope for this provider.

Copy link
Member

Choose a reason for hiding this comment

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

I removed the statement of removal from the comment and we can determine in a later issue if that's something we want to do ⚡

@austinvalle austinvalle changed the title Fix unable to generate passwords with >72 characters Prevent hash error bcrypt.ErrPasswordTooLong for passwords > 72 bytes in length Apr 12, 2023
@austinvalle austinvalle merged commit f1c7ffa into main Apr 12, 2023
@austinvalle austinvalle deleted the bendbennett/issues-396 branch April 12, 2023 20:13
dduportal referenced this pull request in jenkins-infra/azure Sep 23, 2023
<Actions>
<action
id="40b8caa65227ee1ff402dd788d378a3dd5493dc0870df6841ca819e93c79246a">
        <h3>Bump Terraform `random` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>&#34;hashicorp/random&#34; updated from &#34;3.5.1&#34; to
&#34;3.5.1&#34; in file &#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>3.5.1</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-random/releases/tag/v3.5.1&#xA;BUG
FIXES:&#xA;&#xA;* resource/random_password: Prevent error with `bcrypt`
by truncating the bytes that are hashed to a maximum length of 72
([#397](https://github.com/hashicorp/terraform-provider-random/issues/397))&#xA;&#xA;&#xA;</pre>
            </details>
        </details>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <60776566+jenkins-infra-bot@users.noreply.github.com>
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to generate passwords with >72 characters
4 participants