2

When adding the below style attribute on a popular website in IE7 emulator nothing happened, but when I execute it from a trivial website in IE7 emulator it does get executed.

<body style="width: expression(alert())">

How can you prevent the expression from being executed?

3
  • ie7 is long dead from microsoft perspective. Commented Dec 22, 2016 at 0:52
  • Is this really an XSS problem? Would you allow your site's users to edit its styles? Commented Dec 22, 2016 at 1:03
  • @user3553031 I would also like to know what security measures can be taken for today supported browsers please. @/DanielA.White It's more about how the problem is solved than the problem itself. @/nnnnnn I would never let users do that, but I would like to know what to add so that if someone did it, we're safe Commented Dec 22, 2016 at 1:21

2 Answers 2

1

As a mitigation against JavaScript being injected in unexpected places in modern browsers, use a content security policy. For instance, a CSP of script-src: none; will deny all JavaScript execution within your page, regardless of where it originated. More nuanced policies can be designed to allow JavaScript only from specific URIs, or only scripts with specific hashes.

Sign up to request clarification or add additional context in comments.

2 Comments

This is good for XSS, but here the malcious code comes from 'self'. But it's a good resource, thank you!
This will not prevent HTC nor expression to be executed since it only works from IE11. But I agree it is a good first level of defense! Does your Javascript code gets executed when you deny javascript execution from self or is the self option for a JSF app?
0

The feature you are talking about is called Dynamic Properties and is no longer supported as of IE8.

Dynamic properties (also called "CSS expressions") are no longer supported in Internet Explorer 8 and later, in IE8 Standards mode and higher. This decision was made for standards compliance, browser performance, and security reasons. Dynamic properties are still available in Internet Explorer 8 in either IE7 mode or IE5 mode. (For more information about document compatibility modes, see Defining Document Compatibility.) Because Internet Explorer 8 in IE8 mode is fully compliant with the Cascading Style Sheets, Level 2 Revision 1 (CSS2.1) standard, most dynamic properties written to work around Cascading Style Sheets (CSS)-related shortcomings in previous versions of Internet Explorer should no longer be needed. Other dynamic properties with more specific uses can generally be replaced with standard JavaScript.

2 Comments

So how does this answer the question about how it works or how to prevent it in IE7?
I know it's not supported and deprecated, I want to know how they fixed this 5 years ago. Because that kind of issue still exist with HTC until IE9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.