Course contentsShow
← Web Development
Lesson 2849 of 2,98251. Content Security PolicyFree lesson

The object-src Directive

Restricting plugins like Flash with object-src, typically set to 'none' in modern applications.

The object-src Directive

You'll learn how to block legacy plugins like Flash from running on your site using the object-src directive in Content Security Policy.

What It Does

The object-src directive controls where <object>, <embed>, and <applet> elements can load their resources from. These HTML elements were historically used to embed browser plugins like Adobe Flash, Java applets, and Silverlight—technologies that are now deprecated and considered serious security risks.

Why You Almost Always Set It to 'none'

Modern web applications have no legitimate need for plugin-based content. Flash reached end-of-life in 2020, and browsers have removed support for most plugins. These technologies had numerous security vulnerabilities and bypassed many browser security features.

Setting object-src to 'none' is a best practice that prevents attackers from injecting plugin-based exploits into your site, even if they manage to inject malicious HTML.

How to Use It

Content-Security-Policy: default-src 'self'; object-src 'none'

This tells the browser: "Block all attempts to load plugins, period."

If you somehow still need plugin content (highly unlikely), you could specify sources:

Content-Security-Policy: object-src 'self' https://trusted-legacy.example.com

But in 2024, you should really be migrating away from any plugin dependencies.

Think of It As...

Imagine object-src 'none' as removing the electrical outlets for obsolete, fire-hazard appliances from your building. Even if someone tries to plug one in, it simply won't work—keeping everyone safer by design.

Key Takeaway: Always set object-src 'none' in your CSP to block legacy plugin content, which has no place in modern web applications and poses significant security risks.