[GH-ISSUE #453] fail to create ns secret #327

Open
opened 2026-02-26 10:30:53 +03:00 by kerem · 13 comments
Owner

Originally created by @adrienb4 on GitHub (Jan 17, 2020).
Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/453

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 0a625d6853

Thx

Originally created by @adrienb4 on GitHub (Jan 17, 2020). Original GitHub issue: https://github.com/nsupdate-info/nsupdate.info/issues/453 Hi We can't generate a ns secret. ![image](https://user-images.githubusercontent.com/15191572/72623090-c7bf8c00-3944-11ea-850f-59e50d78e84c.png) 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](https://user-images.githubusercontent.com/15191572/72623577-ab701f00-3945-11ea-96ce-a2aca0a48ba6.png) Commit 0a625d685358fa668a46eea63b1c73ef84a6442b Thx
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 17, 2020):

@elnappo ^^^

<!-- gh-comment-id:575671981 --> @ThomasWaldmann commented on GitHub (Jan 17, 2020): @elnappo ^^^
Author
Owner
<!-- gh-comment-id:576224408 --> @elnappo commented on GitHub (Jan 20, 2020): Hmm, we haven't changed the length of this field. It was always 88 https://github.com/nsupdate-info/nsupdate.info/blob/master/src/nsupdate/main/models.py#L103 https://github.com/nsupdate-info/nsupdate.info/search?q=nameserver_update_secret&unscoped_q=nameserver_update_secret
Author
Owner

@adrienb4 commented on GitHub (Jan 20, 2020):

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.

<!-- gh-comment-id:576228615 --> @adrienb4 commented on GitHub (Jan 20, 2020): 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.
Author
Owner

@elnappo commented on GitHub (Jan 20, 2020):

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

<!-- gh-comment-id:576290746 --> @elnappo commented on GitHub (Jan 20, 2020): On nsupdate.info my nameserver update secrets are 88 chars long. @ThomasWaldmann do you have an idea?
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 20, 2020):

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.

<!-- gh-comment-id:576398614 --> @ThomasWaldmann commented on GitHub (Jan 20, 2020): 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.
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 20, 2020):

@adrienb4 how do your generated secrets look like?

<!-- gh-comment-id:576398915 --> @ThomasWaldmann commented on GitHub (Jan 20, 2020): @adrienb4 how do your generated secrets look like?
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 20, 2020):

is it related to #447?

<!-- gh-comment-id:576401579 --> @ThomasWaldmann commented on GitHub (Jan 20, 2020): is it related to #447?
Author
Owner

@adrienb4 commented on GitHub (Jan 21, 2020):

For example with a domain secret created by nsupdate :

SmtQUHpzWW5mZlZRNkdnYmJabnBFQ01nc21hN3VrekZGTWR0RVU2RjVZOGtXdlJaNDR4SkIzQkZIRVE0SDZGTQ==

Len is 89.

image

<!-- gh-comment-id:576557098 --> @adrienb4 commented on GitHub (Jan 21, 2020): For example with a domain secret created by nsupdate : ``` SmtQUHpzWW5mZlZRNkdnYmJabnBFQ01nc21hN3VrekZGTWR0RVU2RjVZOGtXdlJaNDR4SkIzQkZIRVE0SDZGTQ== ``` Len is 89. ![image](https://user-images.githubusercontent.com/15191572/72784782-dd290480-3c29-11ea-9969-d624f789a269.png)
Author
Owner

@adrienb4 commented on GitHub (Jan 21, 2020):

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==
<!-- gh-comment-id:576559777 --> @adrienb4 commented on GitHub (Jan 21, 2020): 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== ```
Author
Owner

@adrienb4 commented on GitHub (Jan 21, 2020):

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.

<!-- gh-comment-id:576582794 --> @adrienb4 commented on GitHub (Jan 21, 2020): 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.
Author
Owner

@adrienb4 commented on GitHub (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

<!-- gh-comment-id:576684049 --> @adrienb4 commented on GitHub (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](https://user-images.githubusercontent.com/15191572/72809059-29406d00-3c5b-11ea-9036-062cb294f127.png) 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](https://user-images.githubusercontent.com/15191572/72808698-62c4a880-3c5a-11ea-9670-58d872cc71f1.png) See : https://sqlite.org/faq.html#q9
Author
Owner

@ThomasWaldmann commented on GitHub (Jan 23, 2020):

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?

<!-- gh-comment-id:577447183 --> @ThomasWaldmann commented on GitHub (Jan 23, 2020): 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?
Author
Owner

@brice-gros commented on GitHub (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

<!-- gh-comment-id:577573224 --> @brice-gros commented on GitHub (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 in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nsupdate.info-nsupdate-info#327
No description provided.