Skip to content

Commit e59969b

Browse files
authored
Merge pull request #339 from yatoogamii/The-clickjacking-attack
The clickjacking attack
2 parents d7d9bde + 96a3284 commit e59969b

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed
Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
# The clickjacking attack
1+
# L'attaque par clickjacking
22

3-
The "clickjacking" attack allows an evil page to click on a "victim site" *on behalf of the visitor*.
3+
L'attaque par "clickjacking" permet à une page malveillante de cliquer sur un "site victime" *au nom du visiteur*.
44

5-
Many sites were hacked this way, including Twitter, Facebook, Paypal and other sites. They have all been fixed, of course.
5+
De nombreux sites ont été piratés de cette manière, notamment Twitter, Facebook, Paypal et d'autres sites. Ils ont tous été réparés, bien sûr.
66

7-
## The idea
7+
## L'idée
88

9-
The idea is very simple.
9+
L'idée est très simple.
1010

11-
Here's how clickjacking was done with Facebook:
11+
Voici comment le clickjacking a été fait avec Facebook:
1212

13-
1. A visitor is lured to the evil page. It doesn't matter how.
14-
2. The page has a harmless-looking link on it (like "get rich now" or "click here, very funny").
15-
3. Over that link the evil page positions a transparent `<iframe>` with `src` from facebook.com, in such a way that the "Like" button is right above that link. Usually that's done with `z-index`.
16-
4. In attempting to click the link, the visitor in fact clicks the button.
13+
1. Un visiteur est attiré vers la page malveillante. Peu importe comment.
14+
2. La page contient un lien inoffensif (du type "enrichissez-vous maintenant" ou "cliquez ici, très drôle").
15+
3. Au-dessus de ce lien, la page maléfique place un `<iframe>` transparent avec `src` de facebook.com, de telle sorte que le bouton "J'aime" se trouve juste au-dessus de ce lien. Habituellement, cela se fait avec `z-index`.
16+
4. En essayant de cliquer sur le lien, le visiteur clique en fait sur le bouton.
1717

18-
## The demo
18+
## La démo
1919

20-
Here's how the evil page looks. To make things clear, the `<iframe>` is half-transparent (in real evil pages it's fully transparent):
20+
Voici à quoi ressemble la page malveillante. Pour que les choses soient claires, le `<iframe>` est semi-transparent (dans les vraies pages maléfiques, il est totalement transparent):
2121

2222
```html run height=120 no-beautify
2323
<style>
24-
iframe { /* iframe from the victim site */
24+
iframe { /* iframe du site de la victime */
2525
width: 400px;
2626
height: 100px;
2727
position: absolute;
2828
top:0; left:-20px;
2929
*!*
30-
opacity: 0.5; /* in real opacity:0 */
30+
opacity: 0.5; /* en réalité opacity:0 */
3131
*/!*
3232
z-index: 1;
3333
}
3434
</style>
3535

3636
<div>Click to get rich now:</div>
3737

38-
<!-- The url from the victim site -->
38+
<!-- L'url du site de la victime -->
3939
*!*
4040
<iframe src="/clickjacking/facebook.html"></iframe>
4141

@@ -45,102 +45,102 @@ iframe { /* iframe from the victim site */
4545
<div>...And you're cool (I'm a cool hacker actually)!</div>
4646
```
4747

48-
The full demo of the attack:
48+
La démo complète de l'attaque:
4949

5050
[codetabs src="clickjacking-visible" height=160]
5151

52-
Here we have a half-transparent `<iframe src="facebook.html">`, and in the example we can see it hovering over the button. A click on the button actually clicks on the iframe, but that's not visible to the user, because the iframe is transparent.
52+
Ici, nous avons un `<iframe src="facebook.html">` semi-transparent, et dans l'exemple, nous pouvons le voir planer au-dessus du bouton. En cliquant sur le bouton, on clique en fait sur l'iframe, mais l'utilisateur ne le voit pas, car l'iframe est transparent.
5353

54-
As a result, if the visitor is authorized on Facebook ("remember me" is usually turned on), then it adds a "Like". On Twitter that would be a "Follow" button.
54+
Par conséquent, si le visiteur est connecté sur Facebook (l'option "Se souvenir de moi" est généralement activée), un bouton "J'aime" est ajouté. Sur Twitter, ce serait un bouton "Suivre".
5555

56-
Here's the same example, but closer to reality, with `opacity:0` for `<iframe>`:
56+
Voici le même exemple, mais plus proche de la réalité, avec `opacity:0` pour `<iframe>`:
5757

5858
[codetabs src="clickjacking" height=160]
5959

60-
All we need to attack -- is to position the `<iframe>` on the evil page in such a way that the button is right over the link. So that when a user clicks the link, they actually click the button. That's usually doable with CSS.
60+
Tout ce dont nous avons besoin pour attaquer -- c'est de positionner le `<iframe>` sur la page malveillante de manière à ce que le bouton soit juste au-dessus du lien. Ainsi, lorsqu'un utilisateur clique sur le lien, il clique en fait sur le bouton. C'est généralement faisable avec CSS.
6161

62-
```smart header="Clickjacking is for clicks, not for keyboard"
63-
The attack only affects mouse actions (or similar, like taps on mobile).
62+
```smart header="Le clickjacking est pour les clics, pas pour le clavier"
63+
L'attaque n'affecte que les actions de la souris (ou des actions similaires, comme les tapotements sur les mobiles).
6464
65-
Keyboard input is much difficult to redirect. Technically, if we have a text field to hack, then we can position an iframe in such a way that text fields overlap each other. So when a visitor tries to focus on the input they see on the page, they actually focus on the input inside the iframe.
65+
La saisie au clavier est très difficile à rediriger. Techniquement, si nous avons un champ de texte à pirater, nous pouvons alors positionner un iframe de telle sorte que les champs de texte se chevauchent. Ainsi, lorsqu'un visiteur essaie de se concentrer sur la saisie qu'il voit sur la page, il se concentre en fait sur la saisie à l'intérieur de l'iframe.
6666
67-
But then there's a problem. Everything that the visitor types will be hidden, because the iframe is not visible.
67+
Mais il y a un problème. Tout ce que le visiteur tape sera caché, car l'iframe n'est pas visible.
6868
69-
People will usually stop typing when they can't see their new characters printing on the screen.
69+
Les gens s'arrêtent généralement de taper lorsqu'ils ne voient pas leurs nouveaux caractères s'imprimer à l'écran.
7070
```
7171

72-
## Old-school defences (weak)
72+
## Défenses de la vieille école (faibles)
7373

74-
The oldest defence is a bit of JavaScript which forbids opening the page in a frame (so-called "framebusting").
74+
La défense la plus ancienne est un bout de JavaScript qui interdit l'ouverture de la page dans un iframe (ce qu'on appelle le "framebusting").
7575

76-
That looks like this:
76+
Cela ressemble à ceci:
7777

7878
```js
7979
if (top != window) {
8080
top.location = window.location;
8181
}
8282
```
8383

84-
That is: if the window finds out that it's not on top, then it automatically makes itself the top.
84+
C'est-à-dire que si la fenêtre découvre qu'elle n'est pas en haut, elle se met automatiquement en haut.
8585

86-
This not a reliable defence, because there are many ways to hack around it. Let's cover a few.
86+
Ce n'est pas une défense fiable, car il existe de nombreuses façons de la contourner. En voici quelques-unes.
8787

88-
### Blocking top-navigation
88+
### Blocage de la navigation supérieure
8989

90-
We can block the transition caused by changing `top.location` in [beforeunload](info:onload-ondomcontentloaded#window.onbeforeunload) event handler.
90+
Nous pouvons bloquer la transition provoquée par le changement de `top.location` dans l'événement [beforeunload](info:onload-ondomcontentloaded#window.onbeforeunload).
9191

92-
The top page (enclosing one, belonging to the hacker) sets a preventing handler to it, like this:
92+
La page du haut (appartenant au pirate) lui attribue un événement de prévention, comme ceci:
9393

9494
```js
9595
window.onbeforeunload = function() {
9696
return false;
9797
};
9898
```
9999

100-
When the `iframe` tries to change `top.location`, the visitor gets a message asking them whether they want to leave.
100+
Lorsque le `iframe` essaie de changer `top.location`, le visiteur reçoit un message lui demandant s'il veut quitter le site.
101101

102-
In most cases the visitor would answer negatively because they don't know about the iframe - all they can see is the top page, there's no reason to leave. So `top.location` won't change!
102+
Dans la plupart des cas, le visiteur répondra négativement parce qu'il ne connaît pas l'iframe - tout ce qu'il peut voir est la page d'accueil, il n'a aucune raison de la quitter. Donc `top.location` ne changera pas!
103103

104-
In action:
104+
En action:
105105

106106
[codetabs src="top-location"]
107107

108-
### Sandbox attribute
108+
### L'attribut Sandbox
109109

110-
One of the things restricted by the `sandbox` attribute is navigation. A sandboxed iframe may not change `top.location`.
110+
L'une des choses limitées par l'attribut `sandbox` est la navigation. Une iframe protégée par un sandbox ne peut pas modifier l'attribut `top.location`.
111111

112-
So we can add the iframe with `sandbox="allow-scripts allow-forms"`. That would relax the restrictions, permitting scripts and forms. But we omit `allow-top-navigation` so that changing `top.location` is forbidden.
112+
Nous pouvons donc ajouter l'iframe avec `sandbox="allow-scripts allow-forms"`. Cela assouplirait les restrictions, autorisant les scripts et les formulaires. Mais nous omettons `allow-top-navigation` pour que la modification de `top.location` soit interdite.
113113

114-
Here's the code:
114+
Voici le code:
115115

116116
```html
117117
<iframe *!*sandbox="allow-scripts allow-forms"*/!* src="facebook.html"></iframe>
118118
```
119119

120-
There are other ways to work around that simple protection too.
120+
Il existe également d'autres moyens de contourner cette simple protection.
121121

122122
## X-Frame-Options
123123

124-
The server-side header `X-Frame-Options` can permit or forbid displaying the page inside a frame.
124+
L'en-tête `X-Frame-Options` côté serveur peut autoriser ou interdire l'affichage de la page dans un iframe.
125125

126-
It must be sent exactly as HTTP-header: the browser will ignore it if found in HTML `<meta>` tag. So, `<meta http-equiv="X-Frame-Options"...>` won't do anything.
126+
Il doit être envoyé exactement comme un en-tête HTTP : le navigateur l'ignorera s'il se trouve dans la balise HTML `<meta>`. Ainsi, `<meta http-equiv="X-Frame-Options"...>` ne fera rien.
127127

128-
The header may have 3 values:
128+
L'en-tête peut avoir 3 valeurs:
129129

130130

131131
`DENY`
132-
: Never ever show the page inside a frame.
132+
: Ne jamais afficher la page à l'intérieur d'un iframe.
133133

134134
`SAMEORIGIN`
135-
: Allow inside a frame if the parent document comes from the same origin.
135+
: Autoriser à l'intérieur d'un iframe si le document parent a la même origine..
136136

137137
`ALLOW-FROM domain`
138-
: Allow inside a frame if the parent document is from the given domain.
138+
: Autoriser à l'intérieur d'un iframe si le document parent appartient au domaine donné..
139139

140-
For instance, Twitter uses `X-Frame-Options: SAMEORIGIN`.
140+
Par exemple, Twitter utilise `X-Frame-Options: SAMEORIGIN`.
141141

142142
````online
143-
Here's the result:
143+
Voici le résultat:
144144
145145
```html
146146
<iframe src="https://twitter.com"></iframe>
@@ -149,16 +149,16 @@ Here's the result:
149149
<!-- ebook: prerender/ chrome headless dies and timeouts on this iframe -->
150150
<iframe src="https://twitter.com"></iframe>
151151
152-
Depending on your browser, the `iframe` above is either empty or alerting you that the browser won't permit that page to be navigating in this way.
152+
Selon votre navigateur, le `iframe` ci-dessus est soit vide, soit vous avertit que le navigateur ne permet pas de naviguer sur cette page de cette manière.
153153
````
154154

155-
## Showing with disabled functionality
155+
## Affichage de la fonctionnalité désactivée
156156

157-
The `X-Frame-Options` header has a side-effect. Other sites won't be able to show our page in a frame, even if they have good reasons to do so.
157+
L'en-tête `X-Frame-Options` a un effet secondaire. Les autres sites ne pourront pas afficher notre page dans un iframe, même s'ils ont de bonnes raisons de le faire.
158158

159-
So there are other solutions... For instance, we can "cover" the page with a `<div>` with styles `height: 100%; width: 100%;`, so that it will intercept all clicks. That `<div>` is to be removed if `window == top` or if we figure out that we don't need the protection.
159+
Il existe donc d'autres solutions... Par exemple, on peut "couvrir" la page avec une `<div>` avec les styles `height : 100% ; width : 100%;`, pour qu'elle intercepte tous les clics. Cette `<div>` doit être retirée si `window == top` ou si l'on s'aperçoit que l'on n'a pas besoin de cette protection.
160160

161-
Something like this:
161+
Quelque chose comme ça:
162162

163163
```html
164164
<style>
@@ -177,45 +177,45 @@ Something like this:
177177
</div>
178178

179179
<script>
180-
// there will be an error if top window is from the different origin
181-
// but that's ok here
180+
// il y aura une erreur si la fenêtre supérieure est d'une origine différente
181+
// mais c'est bon ici
182182
if (top.document.domain == document.domain) {
183183
protector.remove();
184184
}
185185
</script>
186186
```
187187

188-
The demo:
188+
La démo:
189189

190190
[codetabs src="protector"]
191191

192-
## Samesite cookie attribute
192+
## Attribut de cookie "samesite"
193193

194-
The `samesite` cookie attribute can also prevent clickjacking attacks.
194+
L'attribut de cookie `samesite` peut également prévenir les attaques de clickjacking.
195195

196-
A cookie with such attribute is only sent to a website if it's opened directly, not via a frame, or otherwise. More information in the chapter <info:cookie#samesite>.
196+
Un cookie avec un tel attribut n'est envoyé à un site web que s'il est ouvert directement, et non par l'intermédiaire d'un iframe ou autre. Plus d'informations dans le chapitre <info:cookie#samesite>.
197197

198-
If the site, such as Facebook, had `samesite` attribute on its authentication cookie, like this:
198+
Si le site, tel que Facebook, avait l'attribut `samesite` dans son cookie d'authentification, comme ceci:
199199

200200
```
201201
Set-Cookie: authorization=secret; samesite
202202
```
203203

204-
...Then such cookie wouldn't be sent when Facebook is open in iframe from another site. So the attack would fail.
204+
...Ce cookie ne serait donc pas envoyé lorsque Facebook est ouvert dans une iframe depuis un autre site. Donc l'attaque échoue.
205205

206-
The `samesite` cookie attribute will not have an effect when cookies are not used. This may allow other websites to easily show our public, unauthenticated pages in iframes.
206+
L'attribut de cookie `samesite` n'aura pas d'effet lorsque les cookies ne sont pas utilisés. Cela peut permettre à d'autres sites Web d'afficher facilement nos pages publiques, non authentifiées, dans des iframes.
207207

208-
However, this may also allow clickjacking attacks to work in a few limited cases. An anonymous polling website that prevents duplicate voting by checking IP addresses, for example, would still be vulnerable to clickjacking because it does not authenticate users using cookies.
208+
Toutefois, cela peut également permettre aux attaques par détournement de clics de fonctionner dans quelques cas limités. Un site Web de vote anonyme qui empêche les doubles votes en vérifiant les adresses IP, par exemple, serait toujours vulnérable au détournement de clics parce qu'il n'authentifie pas les utilisateurs à l'aide de cookies.
209209

210-
## Summary
210+
## Résumé
211211

212-
Clickjacking is a way to "trick" users into clicking on a victim site without even knowing what's happening. That's dangerous if there are important click-activated actions.
212+
Le détournement de clics est un moyen de "tromper" les utilisateurs en les incitant à cliquer sur un site victime sans même savoir ce qui se passe. C'est dangereux s'il y a des actions importantes activées par le clic.
213213

214-
A hacker can post a link to their evil page in a message, or lure visitors to their page by some other means. There are many variations.
214+
Un hacker peut poster un lien vers sa page malveillante dans un message, ou attirer les visiteurs sur sa page par d'autres moyens. Il existe de nombreuses variantes.
215215

216-
From one perspective -- the attack is "not deep": all a hacker is doing is intercepting a single click. But from another perspective, if the hacker knows that after the click another control will appear, then they may use cunning messages to coerce the user into clicking on them as well.
216+
D'un certain point de vue, l'attaque n'est "pas profonde" : le pirate ne fait qu'intercepter un seul clic. Mais d'un autre point de vue, si le pirate sait qu'après le clic, un autre contrôle apparaîtra, il peut utiliser des messages astucieux pour contraindre l'utilisateur à cliquer également sur ces contrôles.
217217

218-
The attack is quite dangerous, because when we engineer the UI we usually don't anticipate that a hacker may click on behalf of the visitor. So vulnerabilities can be found in totally unexpected places.
218+
Cette attaque est assez dangereuse, car lorsque nous concevons l'interface utilisateur, nous ne prévoyons généralement pas qu'un pirate puisse cliquer au nom du visiteur. Les vulnérabilités peuvent donc se trouver dans des endroits totalement inattendus.
219219

220-
- It is recommended to use `X-Frame-Options: SAMEORIGIN` on pages (or whole websites) which are not intended to be viewed inside frames.
221-
- Use a covering `<div>` if we want to allow our pages to be shown in iframes, but still stay safe.
220+
- Il est recommandé d'utiliser `X-Frame-Options : SAMEORIGIN` sur les pages (ou les sites entiers) qui ne sont pas destinées à être affichées dans des iframes.
221+
- Utilisez une couverture `<div>` si nous voulons permettre à nos pages d'être affichées dans des iframes, tout en restant sécurisées.

0 commit comments

Comments
 (0)