logo

Database

Rust Dynamodb Nosql Injection

Description

This detector identifies NoSQL injection vulnerabilities in Rust applications using AWS DynamoDB. It finds locations where user-controlled data from Actix Web requests is directly used in DynamoDB expressions without proper sanitization, allowing attackers to manipulate database queries and potentially access or modify unauthorized data.

Weakness:

106 - NoSQL injection

Category: Unexpected Injection

Detection Strategy

    The code must import both AWS SDK DynamoDB library (aws_sdk_dynamodb) and Actix Web framework (actix_web)

    The detector scans for vulnerable DynamoDB expression patterns where user input flows into database query expressions

    A vulnerability is reported when user-controlled data from web requests is used directly in DynamoDB operations without proper validation or parameterization

Vulnerable code example

use aws_sdk_dynamodb::Client;
use aws_sdk_dynamodb::types::AttributeValue;
use std::collections::HashMap;

// DynamoDB Expression Injection vulnerability
async fn vulnerable_dynamodb_query(
    client: &Client,
    user_input: &str,...

✅ Secure code example

use aws_sdk_dynamodb::Client;
use aws_sdk_dynamodb::types::AttributeValue;
use std::collections::HashMap;

// FIXED: Using parameterized expressions to prevent injection
async fn safe_dynamodb_query(
    client: &Client,
    user_input: &str,...