Skip to content

Fix: prevent silent password overwrite on contact/domain update#264

Merged
ehsan-fj merged 2 commits intoInternetNZ:developfrom
yuriverweij:fix/password-silently-overwritten
Mar 10, 2026
Merged

Fix: prevent silent password overwrite on contact/domain update#264
ehsan-fj merged 2 commits intoInternetNZ:developfrom
yuriverweij:fix/password-silently-overwritten

Conversation

@yuriverweij
Copy link
Copy Markdown
Contributor

Fix: prevent silent password overwrite on contact/domain update

Problem

When calling Contact.update() or Domain.update() without supplying a
password, the existing registry password was silently overwritten with a
randomly generated one.

Root cause: base_command._prepare_command auto-generated a 16-character
password for any command template that contained the word password — which
includes update templates even after the conditional {% if password %} fix
in fe0175d. The auto-generated password satisfied the Jinja condition, causing
the <authInfo> block to be included in the XML and the password to be
overwritten on the EPP server.

Solution

Moved password auto-generation out of base_command._prepare_command and into
the specific create() methods that actually require it:

  • base_command._prepare_command — removed auto-generation logic and the
    now-unused helper import
  • contact.create() — explicitly generates a password when none is
    provided
  • domain.create() — explicitly generates a password when none is
    provided

Update operations no longer touch the password unless one is explicitly
supplied by the caller.

Tests

  • Replaced the old test_prepare_command_password (which asserted
    auto-generation) with two new tests that assert:
    • no password is injected when none is supplied
    • an explicitly supplied password passes through correctly
  • Added test_create_generates_password_when_not_supplied and
    test_update_does_not_generate_password_when_not_supplied for both
    Contact and Domain

yuriverweij and others added 2 commits March 9, 2026 10:45
Only include the password in Contact Update when supplying a password. To prevent silently overwriting the password.
…d domain creation; update tests accordingly
@ehsan-fj ehsan-fj self-requested a review March 9, 2026 20:39
Copy link
Copy Markdown
Member

@ehsan-fj ehsan-fj left a comment

Choose a reason for hiding this comment

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

Thanks for your PR.

@ehsan-fj ehsan-fj merged commit 8abe789 into InternetNZ:develop Mar 10, 2026
1 check passed
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.

2 participants