logo

Database

Rust Actix Cors Permissive Policy

Description

This vulnerability detects permissive Cross-Origin Resource Sharing (CORS) configurations in Rust Actix web applications that allow unrestricted cross-origin access. Overly permissive CORS policies can expose the application to cross-origin attacks, allowing malicious websites to access sensitive resources and data.

Weakness:

134 - Insecure or unset HTTP headers - CORS

Category: Protocol Manipulation

Detection Strategy

    Scans Rust source code files that import the actix_web library

    Identifies CORS configuration patterns that set overly permissive access policies

    Reports violations when CORS headers are configured to allow all origins (*) or when actix_cors crate builder methods create unrestricted access policies

    Triggers alerts on method calls and header configurations that bypass same-origin policy protections

Vulnerable code example

use actix_cors::Cors;
use actix_web::middleware::DefaultHeaders;
use actix_web::{middleware, App, HttpResponse};

// Vulnerable - Cors::permissive() allows all origins/methods/headers
fn app_vulnerable() -> App<()> {
    App::new().wrap(Cors::permissive())
}...

✅ Secure code example

use actix_cors::Cors;
use actix_web::middleware::DefaultHeaders;
use actix_web::{middleware, App, HttpResponse};

// Safe - Specify allowed origins explicitly instead of permissive wildcard
fn app_safe() -> App<()> {
    App::new().wrap(
        Cors::default()...