Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DX] Log potential redirect loops caused by forced HTTPS#27605

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@colinodell
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#27603
LicenseMIT
Doc PRn/a

If the developer forgets/fails to set "trusted_proxies" properly, forcing the
https channel can cause infinite redirect loops. This change will hopefully
help them identify the problem faster.

See#27603

Aerendir and GromNaN reacted with heart emoji
@carsonbotcarsonbot added Status: Needs Review DXDX = Developer eXperience (anything that improves the experience of using Symfony) Feature labelsJun 14, 2018
@colinodell
Copy link
ContributorAuthor

I have also submittedsymfony/symfony-docs#9924 to help point developers in the right direction via documentation.That PR does not document this change, it just provides a different avenue to notify the developer about the potential issue. Feel free to merge that instead of this (or merge both! 😃)

fabiofdsantos reacted with thumbs up emoji

if (null !==$this->logger) {
$this->logger->info('Redirecting to HTTPS.');
if ('https' ===$request->headers->get('X-Forwarded-Proto')) {
$this->logger->debug('Possible redirect loop - did you set "trusted_proxies" correctly?');
Copy link
Contributor

Choose a reason for hiding this comment

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

What aboutwarn?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This log message could be triggered by anybody who sends HTTP requests to the server with that header:

curl http://www.example.com -H'X-Forwarded-Proto: https'

If the site is configured to log messages with a minimum severity ofwarn or higher then their logs could potentially be flooded with "false positives". Usingdebug() would prevent that from happening unless the site is configured to logdebug messages (which I'd assume somebody might do if they had an unexpected redirect loop and were looking for clues).

That being said, I'm not strongly opposed to using a different log level if others feel that it is more appropriate.

maxhelias reacted with thumbs up emoji

Choose a reason for hiding this comment

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

since there is already an info level message, we could merge the new with the existing one:
$this->logger->info('Redirecting to HTTPS ("X-Forwarded-Proto" is set to "https" - did you set "trusted_proxies" correctly?).');

fabiofdsantos reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Good idea! I've made it so that only one message will ever be logged.

if ('https' ===$channel && !$request->isSecure()) {
if (null !==$this->logger) {
$this->logger->info('Redirecting to HTTPS.');
if ('https' ===$request->headers->get('X-Forwarded-Proto')) {

Choose a reason for hiding this comment

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

this could also handle rfc7239's "proto" parameter

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I've added an additional check for this parameter.

@colinodellcolinodellforce-pushed thefeature/notify-potential-redirect-loop branch from15748c7 to7714655CompareJune 19, 2018 14:27
If the developer forgets/fails to set "trusted_proxies" properly, forcing thehttps channel can cause infinite redirect loops. This change will hopefullyhelp them identify the problem faster.Seesymfony#27603
@colinodellcolinodellforce-pushed thefeature/notify-potential-redirect-loop branch from7714655 to53048ceCompareJune 19, 2018 14:59
@fabpot
Copy link
Member

Thank you@colinodell.

colinodell reacted with heart emoji

@fabpotfabpot merged commit53048ce intosymfony:masterJun 20, 2018
fabpot added a commit that referenced this pull requestJun 20, 2018
…PS (colinodell)This PR was merged into the 4.2-dev branch.Discussion----------[DX] Log potential redirect loops caused by forced HTTPS| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#27603| License       | MIT| Doc PR        | n/aIf the developer forgets/fails to set "trusted_proxies" properly, forcing thehttps channel can cause infinite redirect loops. This change will hopefullyhelp them identify the problem faster.See#27603Commits-------53048ce Log potential redirect loops caused by forced HTTPS
@colinodellcolinodell deleted the feature/notify-potential-redirect-loop branchJune 20, 2018 19:55
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+4 more reviewers

@KocKocKoc left review comments

@20uf20uf20uf approved these changes

@fabiofdsantosfabiofdsantosfabiofdsantos approved these changes

@maxheliasmaxheliasmaxhelias approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

DXDX = Developer eXperience (anything that improves the experience of using Symfony)FeatureStatus: Reviewed

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

9 participants

@colinodell@fabpot@javiereguiluz@Koc@nicolas-grekas@20uf@fabiofdsantos@maxhelias@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp