1.1.0 โ€ข Published 8 months ago

@lock-sdk/payload-guard v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

๐Ÿ›ก Payload Guard

A smart and extensible request payload inspection module for the Lock Security Framework. Protect your APIs and web services from malicious input patterns like XSS, SQLi, command injection, SSRF, and more โ€” with configurable modes, caching, and field-level filtering.

๐Ÿš€ Features

  • ๐Ÿงช Detects XSS, SQLi, SSRF, command/path/template injections
  • โš™๏ธ Supports query, params, body, headers, and cookies
  • ๐Ÿ” Block or detect mode per environment
  • ๐Ÿ“ฆ Smart LRU caching to avoid reprocessing

๐Ÿ›  Usage

Basic Example (block malicious content)

import { secure, payloadGuard } from '@lock-sdk/main';

const middleware = secure()(
  payloadGuard({
    detectXSS: true,
    detectSQLi: true,
    detectSSRF: true,
  })
);

โš™๏ธ Configuration

OptionTypeDefaultDescription
mode'block' | 'detect''block'Block immediately or just log/detect
blockStatusCodenumber403Status code when blocked
blockMessagestring'Request blocked due to potential security threat'Error message for blocked responses
checkParts('params' | 'query' | 'body' | 'headers' | 'cookies')[]['params', 'query', 'body', 'headers']Request parts to inspect
excludeHeadersstring[]['authorization', 'cookie', 'set-cookie']Headers to ignore
excludeFieldsstring[][]JSON keys to skip during inspection
detectXSSbooleantrueEnable XSS detection
detectSQLibooleantrueEnable SQL injection detection
detectSSRFbooleantrueEnable SSRF detection
detectCommandInjectionbooleantrueEnable shell injection detection
detectPathTraversalbooleantrueEnable ../ and file path traversal detection
enableCachingbooleantrueEnable LRU-based payload caching
cacheTtlnumber (ms)3600000Cache expiration time
cacheSizenumber10000Max entries in cache
failBehavior'open' | 'closed''open'What to do if the module throws internally

๐Ÿ›ก Maintained By

Lock Team

1.1.0

8 months ago

1.0.0

8 months ago