Reject newlines in email addresses #6161

Closed
opened 2025-11-02 06:46:45 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @NotAFile on GitHub (Oct 16, 2020).

  • Gitea version (or commit ref): 1.12.5
  • Git version: n/a
  • Operating system: Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: n/a

Description

When clearing out some spam accounts, I noticed that many of them had email addresses that ended with an "\r\n" character sequence, seemingly as one of several strategies of circumventing email address reuse detection.

Gitea should probably not accept email addresses with newlines in them as valid.

Originally created by @NotAFile on GitHub (Oct 16, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.5 - Git version: n/a - Operating system: Linux - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: n/a ## Description When clearing out some spam accounts, I noticed that many of them had email addresses that ended with an "\r\n" character sequence, seemingly as one of several strategies of circumventing email address reuse detection. Gitea should probably not accept email addresses with newlines in them as valid.
Author
Owner

@6543 commented on GitHub (Oct 16, 2020):

I would say: white & blacklist func for email addresses?

@6543 commented on GitHub (Oct 16, 2020): I would say: white & blacklist func for email addresses?
Author
Owner

@techknowlogick commented on GitHub (Oct 17, 2020):

@6543 we currently have that for emails, but the email validity should just know that those characters are invalid

@techknowlogick commented on GitHub (Oct 17, 2020): @6543 we currently have that for emails, but the email validity should just know that those characters are invalid
Author
Owner

@zeripath commented on GitHub (Oct 17, 2020):

OK if we want to get in to this we will need to read:

https://en.wikipedia.org/wiki/Email_address

https://tools.ietf.org/html/rfc3696

https://tools.ietf.org/html/rfc5321

https://tools.ietf.org/html/rfc5322

@zeripath commented on GitHub (Oct 17, 2020): OK if we want to get in to this we will need to read: https://en.wikipedia.org/wiki/Email_address https://tools.ietf.org/html/rfc3696 https://tools.ietf.org/html/rfc5321 https://tools.ietf.org/html/rfc5322
Author
Owner

@NotAFile commented on GitHub (Oct 17, 2020):

I should note that the format was localpart@domain\r\n, which does not make sense and is definitely not valid. The localpart of email addresses is very liberal, but the latter part is much more strict and newlines are not valid in DNS.

@NotAFile commented on GitHub (Oct 17, 2020): I should note that the format was `localpart@domain\r\n`, which does not make sense and is definitely not valid. The localpart of email addresses is very liberal, but the latter part is much more strict and newlines are not valid in DNS.
Author
Owner

@chrisshyi commented on GitHub (Oct 30, 2020):

I can work on this if nobody's been assigned yet!

@chrisshyi commented on GitHub (Oct 30, 2020): I can work on this if nobody's been assigned yet!
Author
Owner

@6543 commented on GitHub (Oct 30, 2020):

@chrisshyi go on for it 👍

If you have questions just ask us on discord ...

@6543 commented on GitHub (Oct 30, 2020): @chrisshyi go on for it 👍 If you have questions just ask us on discord ...
Author
Owner

@6543 commented on GitHub (Apr 3, 2021):

email is now Validated via models.ValidateEmail() witch use mail.ParseAddress()

-> https://golang.org/pkg/net/mail/#ParseAddress

@6543 commented on GitHub (Apr 3, 2021): email is now Validated via `models.ValidateEmail()` witch use `mail.ParseAddress()` -> https://golang.org/pkg/net/mail/#ParseAddress
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6161