Skip to content

Commit

Permalink
Revert "Adjust description to fit improved detection (#3786)" (#3822)
Browse files Browse the repository at this point in the history
This reverts commit 49c5b1f.
  • Loading branch information
daniel-teuchert-sonarsource authored Mar 26, 2024
1 parent 49c5b1f commit 9a2a6c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rules/S5148/html/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ include::../description.adoc[]

include::../ask-yourself.adoc[]

include::../recommended.adoc[]

== Sensitive Code Example

[source,html]
----
<a href="http://example.com/" rel="opener" target="_blank"> <!-- Sensitive -->
<a href="http://example.com/dangerous" target="_blank"> <!-- Sensitive -->
<a href="{{variable}}" rel="opener" target="_blank"> <!-- Sensitive -->
<a href="{{variable}}" target="_blank"> <!-- Sensitive -->
----

== Compliant Solution

In Chrome 88+, Firefox 79+ or Safari 12.1+ ``++target=_blank++`` on anchors implies ``++rel=noopener++`` which makes the protection enabled by default.
To prevent pages from abusing ``++window.opener++``, use ``++rel=noopener++`` on ``++<a href=>++`` to force its value to be ``++null++`` on the opened pages.

[source,html]
----
<a href="https://example.com/" target="_blank" >
<a href="http://petssocialnetwork.io" target="_blank" rel="noopener">
----

== Exceptions
Expand All @@ -26,7 +28,7 @@ No Issue will be raised when ``++href++`` contains a hardcoded relative url as t

[source,html]
----
<a href="internal.html" rel="opener" target="_blank" >
<a href="internal.html" target="_blank" >
----

include::../see.adoc[]
Expand Down
2 changes: 2 additions & 0 deletions rules/S5148/recommended.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
== Recommended Secure Coding Practices

Use ``++noopener++`` to prevent untrusted pages from abusing ``++window.opener++``.

Note: In Chrome 88+, Firefox 79+ or Safari 12.1+ ``++target=_blank++`` on anchors implies ``++rel=noopener++`` which make the protection enabled by default.

0 comments on commit 9a2a6c7

Please sign in to comment.