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

[HtmlSanitizer] Add support for securing links#60539

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

Open
Spomky wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromSpomky:features/safe-target-blank

Conversation

Spomky
Copy link
Contributor

@SpomkySpomky commentedMay 25, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix #
LicenseMIT

IntroduceensureSafeBlankTarget to automatically addrel="noopener noreferrer" to<a> elements withtarget="_blank", mitigating reverse tabnabbing risks.

<!-- Before --><ahref="https://site.example"target="_blank">Outgoing link</a><!-- After --><ahref="https://site.example"target="_blank"rel="noopener noreferrer">Outgoing link</a>

TheallowUnsafeBlankTargets method allows opting out of this behavior if needed.

ℹ️ Info: Modern browsers already considernoopener event if missing. However the presence of therel attribute is still considered as [a good practice]
(https://cheatsheetseries.owasp.org/cheatsheets/HTML5_Security_Cheat_Sheet.html#tabnabbing) by the OWASP.
⚠ Warning: I modifiedNode::setAttribute to allow overwriting existing attributes. I might have missed the reason for the commentAlways use only the first declaration (ease sanitization).
⚠ Warning: The logic is implemented inDomVisitor. It works, however I am wondering if an abstraction is needed.

Introduce `ensureSafeBlankTarget` to automatically add `rel="noopener noreferrer"` to `<a>` elements with `target="_blank"`, mitigating reverse tabnabbing risks. The `allowUnsafeBlankTargets` method allows opting out of this behavior if needed. Included tests validate the new functionality.
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.3" but it seems your PR description refers to branch "7.4".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@nicolas-grekas
Copy link
Member

/cc@tgalopin can you please check this PR?

@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

4 participants
@Spomky@carsonbot@nicolas-grekas@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp