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

fail to create ns secret #453

Open
adrienb4 opened this issue Jan 17, 2020 · 13 comments
Open

fail to create ns secret #453

adrienb4 opened this issue Jan 17, 2020 · 13 comments

Comments

@adrienb4
Copy link

adrienb4 commented Jan 17, 2020

Hi

We can't generate a ns secret.

image

Logs :

django.db.utils.DataError: (1406, "Data too long for column 'nameserver_update_secret' at row 1")

HMAC_SHA512 secret need to have a length to 89, but you set it to 88 in the last migration file.

image

Commit 0a625d6

Thx

@ThomasWaldmann
Copy link
Member

@elnappo ^^^

@adrienb4
Copy link
Author

In my case all HMAC-SHA512 secrets have 89 for length.
I recently upgraded nsupdate and now I can't add new domains.
All domains secret are been generated by nsupdate before upgrading.

@elnappo
Copy link
Member

elnappo commented Jan 20, 2020

On nsupdate.info my nameserver update secrets are 88 chars long. @ThomasWaldmann do you have an idea?

@ThomasWaldmann
Copy link
Member

I tried to add a new domain: len = 88

Then I created a new configuration / new secret for the same domain: len = 88, too.

So, I can't reproduce.

@ThomasWaldmann
Copy link
Member

@adrienb4 how do your generated secrets look like?

@ThomasWaldmann
Copy link
Member

is it related to #447?

@adrienb4
Copy link
Author

For example with a domain secret created by nsupdate :

SmtQUHpzWW5mZlZRNkdnYmJabnBFQ01nc21hN3VrekZGTWR0RVU2RjVZOGtXdlJaNDR4SkIzQkZIRVE0SDZGTQ==

Len is 89.

image

@adrienb4
Copy link
Author

I just generated a new secret domain in CLI :

dnssec-keygen -a HMAC-SHA512 -b 512 -n HOST tata.dyn.toto.fr

Len is 89 too

uP4TqSMiUQUkPrInsaI77WH6up28yKI+36Kp44Aq3e9P+JDQ4toXpCRxCTkU8lhSJyLL6lGbXgoX6WWNjOB/AQ==

@adrienb4
Copy link
Author

Hummm as much for me :/

echo -n 'uP4TqSMiUQUkPrInsaI77WH6up28yKI+36Kp44Aq3e9P+JDQ4toXpCRxCTkU8lhSJyLL6lGbXgoX6WWNjOB/AQ==' | wc -c
88
echo 'uP4TqSMiUQUkPrInsaI77WH6up28yKI+36Kp44Aq3e9P+JDQ4toXpCRxCTkU8lhSJyLL6lGbXgoX6WWNjOB/AQ==' | wc -c
89

Vscode misled me in error. The first character is 1 not 0.

@adrienb4
Copy link
Author

adrienb4 commented Jan 21, 2020

We have found the origin of the problem.

We think when you have upgrade Django to 2.2.9, you introduce a bug with domain secret.
Django tries to update domain secret with a wrong format. The expected format is a string, however we have a binary.

Domain secret in str mode has a length of 88. In binary mode the length is 91.

image

I also discovered that sqlite was not looking at the size of these fields.... You can put more than 88 characters in this case. Not possible with MySQL (my backend).

image

See : https://sqlite.org/faq.html#q9

@ThomasWaldmann
Copy link
Member

ok, guess it is fixed by #454 - but do we now have invalid secret data in the (sqlite) db?
and why did that even work when reading b'...' from the db?

@brice-gros
Copy link
Contributor

brice-gros commented Jan 23, 2020

good point, I assume that switching from django 1 to 2, make the secrets in sqlite invalid anyway, invalidating any comparison string vs bytes.
By the way, regarding #445, switching from sqlite to postgresql (or mysql), won't be possible either, due to the insertion failing since the varchar's max length constraint is not respected.
So, a migration step verifying and fixing nameserver_update_secret would fix the whole issue, I guess

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

No branches or pull requests

4 participants