Course contentsShow
← Security
Lesson 1217 of 3,05225. Application Security - Secure CodingFree lesson

Secure Defaults and Opt-In Security

Configure systems securely by default and require explicit action to reduce security rather than increase it.

Secure Defaults and Opt-In Security

What you'll learn: How designing systems to be secure by default—requiring explicit action to reduce security rather than increase it—creates safer applications.

The Core Principle

Secure defaults mean your application starts in the most secure state possible, and users or developers must take deliberate action to weaken protections. This flips the traditional model where security features are opt-in (requiring action to enable them) to opt-out (requiring action to disable them).

Think of it like a new smartphone: it ships with a lock screen enabled by default. You must deliberately choose to disable it. If phones required users to enable lock screens, most would never bother—and millions of devices would be left vulnerable.

Why This Matters

Human nature tends toward convenience over security. When security features are optional additions:

  • Developers forget to enable them under deadline pressure
  • Users skip security steps during setup
  • Misconfiguration becomes the norm, not the exception

By making secure behavior the default, you protect users who don't understand the risks and eliminate entire categories of misconfiguration vulnerabilities.

Real-World Applications

  • HTTPS by default: Modern frameworks redirect HTTP to HTTPS automatically rather than requiring manual configuration
  • Strict password policies: Enforced by default; administrators must explicitly weaken them
  • Access control: Start with "deny all" and require explicit permission grants (Principle of Least Privilege)
  • Cookie security flags: Set HttpOnly, Secure, and SameSite by default on all cookies
  • Content Security Policy: Enable restrictive policies from day one

The burden should always be on disabling security, never on enabling it.

Key Takeaway: Design systems to be secure by default and require explicit, deliberate action to reduce security—this protects users from themselves and dramatically reduces misconfiguration vulnerabilities.