Skip to content

Add TRUSTED_HOSTS to Flask config in wikiconfig.py and related docs#2217

Open
UlrichB22 wants to merge 3 commits intomoinwiki:masterfrom
UlrichB22:trusted_hosts
Open

Add TRUSTED_HOSTS to Flask config in wikiconfig.py and related docs#2217
UlrichB22 wants to merge 3 commits intomoinwiki:masterfrom
UlrichB22:trusted_hosts

Conversation

@UlrichB22
Copy link
Copy Markdown
Collaborator

to prevent Host Name Vulnerability.

In production deployments, TRUSTED_HOSTS must be configured correctly. Otherwise, when generating absolute links for password reset, email verification, or similar flows, the application may trust unvalidated Host values, which can cause links in outgoing emails to point to an incorrect or attacker-controlled domain. Using a hostname in the request URL that is not in TRUSTED_HOSTS may lead to a "HTTP 400 - Bad Request"-Error with a message like "Host <hostname> is not trusted.".



@frontend.errorhandler(BadRequest)
def bad_request(error):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having this error handler in app.py would seem more reasonable to me. All the frontend views are bundled in a blueprint. Better let's keep the separation and not break it for error handlers.

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