Skip to content

Ultra-low latency RASP for .NET 10. High-performance security engine for high-throughput apps (FinTech/Gaming) with zero-allocation architecture.

License

Notifications You must be signed in to change notification settings

JVBotelho/RASP.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ RASP.Net

.NET 10 Security Architecture Build Coverage Threat Model Reverse Engineering

Runtime Application Self-Protection (RASP) for High-Scale .NET Services
Defense that lives inside your application process, operating at the speed of code.

Important

๐Ÿšง ARCHITECTURAL PREVIEW / ALPHA STAGE

This project is currently in Active Research & Development.

  • Do not deploy to production environments handling real assets (PII, Financial Data) without a full security audit.
  • API Stability: Public interfaces and interception signatures may undergo breaking changes to optimize for zero-allocation performance.
  • Security: While designed to block attacks, this engine is currently being tuned for false positives/negatives.

๐ŸŽฎ Why This Matters for Gaming Security

The Problem: Multiplayer game services process millions of transactions per second. Traditional WAFs introduce network latency and cannot see inside encrypted gRPC payloads or understand game logic context.

The Solution: RASP.Net acts as a last line of defense inside the game server process. It instruments the runtime to detect attacks that bypass perimeter defensesโ€”detecting logic flaws like item duplication exploits or economy manipulation.

Key Engineering Goals:

  1. Zero GC Pressure: Security checks must NOT trigger Garbage Collection pauses that cause frame drops/lag
  2. Sub-Microsecond Latency: Checks happen in nanoseconds, not milliseconds
  3. Defense in Depth: Complements kernel-level Anti-Cheat (BattlEye/EAC) by protecting the backend API layer

โšก Performance Benchmarks

Methodology: BenchmarkDotNet comparing Source Generator (compile-time) vs Reflection (runtime) instrumentation.
Hardware: AMD Ryzen 7 7800X3D | Runtime: .NET 10.0.2 (RyuJIT AVX-512)

Method Scenario Mean Allocated Speedup
Source Generator โœ… Clean Scan 108.9 ns 136 B 10.3x faster ๐Ÿš€
Reflection โœ… Clean Scan 1,120.0 ns 136 B baseline
Source Generator ๐Ÿ›ก๏ธ Attack Blocked 4,090 ns 1,912 B 1.04x faster
Reflection ๐Ÿ›ก๏ธ Attack Blocked 4,260 ns 1,552 B baseline

Key Insights:

  • 10x Faster Hot Path: Source-generated interceptors eliminate runtime reflection overhead, critical for high-throughput game servers
  • Sub-Microsecond Latency: Clean traffic passes through in ~109 nanosecondsโ€”invisible
  • SIMD Optimization: Uses SearchValues<T> for vectorized character scanning before deep inspection

๐Ÿ›ก๏ธ Security Analysis & Threat Modeling

Professional-grade security documentation demonstrating Purple Team capabilities.

Document Description
๐Ÿ“„ Threat Model & Attack Scenarios STRIDE analysis: gRPC SQL Injection, Protobuf Tampering, GC Pressure DoS
๐Ÿ•ต๏ธ Reverse Engineering & Anti-Tamper Native C++ protection: IsDebuggerPresent, PEB manipulation, timing checks

๐Ÿ—๏ธ Architecture

This repository uses a Composite Architecture Strategyโ€”developing and validating the Security SDK by instrumenting a real-world "Victim" application without polluting its source code.

RASP.Net/
โ”œโ”€โ”€ src/                           # ๐Ÿ›ก๏ธ RASP SDK (Defense)
โ”‚   โ”œโ”€โ”€ Rasp.Core/                 # Detection engines & telemetry
โ”‚   โ”œโ”€โ”€ Rasp.SourceGenerators/     # Roslyn code generation
โ”‚   โ”œโ”€โ”€ Rasp.Instrumentation.Grpc/ # gRPC interceptors
โ”‚   โ””โ”€โ”€ Rasp.Bootstrapper/         # DI extensions (AddRasp())
โ”œโ”€โ”€ modules/                       # ๐ŸŽฏ Victim App (Target)
โ”‚   โ””โ”€โ”€ dotnet-grpc-library-api/   # Git submodule - Clean Architecture sample
โ”œโ”€โ”€ attack/                        # โš”๏ธ Red Team Tools
โ”‚   โ”œโ”€โ”€ exploit_xss.py             # XSS attack suite
โ”‚   โ””โ”€โ”€ exploit_grpc.py            # SQLi attack suite
โ””โ”€โ”€ scripts/                       # Automation scripts

๐Ÿ›ก๏ธ How It Works

sequenceDiagram
    participant Attacker
    participant gRPC as gRPC Gateway
    participant RASP as ๐Ÿ›ก๏ธ RASP.Net
    participant GameAPI as Game Service
    participant DB as Database
    
    Note over Attacker,RASP: ๐Ÿ”ด Attack Scenario
    Attacker->>gRPC: POST /inventory/add {item: "Sword' OR 1=1"}
    gRPC->>RASP: Intercept Request
    activate RASP
    RASP->>RASP: โšก Zero-Alloc Inspection
    RASP-->>Attacker: โŒ 403 Forbidden (Threat Detected)
    deactivate RASP
    
    Note over Attacker,DB: ๐ŸŸข Legitimate Scenario
    Attacker->>gRPC: POST /inventory/add {item: "Legendary Sword"}
    gRPC->>RASP: Intercept Request
    activate RASP
    RASP->>GameAPI: โœ… Clean - Forward Request
    deactivate RASP
    GameAPI->>DB: INSERT INTO inventory...
    DB-->>GameAPI: Success
    GameAPI-->>Attacker: 200 OK
Loading

๐Ÿš€ Quick Start

1. Clone with Submodules

git clone --recursive https://github.com/JVBotelho/RASP.Net.git
cd RASP.Net

# If already cloned without --recursive:
git submodule update --init --recursive

2. Build & Run

# Option A: Use automated setup script
./scripts/pack-local.ps1   # Windows
./scripts/pack-local.sh    # Linux/macOS

# Option B: Build directly
dotnet build Rasp.sln

3. Run the Victim App

cd modules/dotnet-grpc-library-api
dotnet run --project LibrarySystem.Grpc

โš”๏ธ Security Testing (Red Team)

Prerequisites

pip install grpcio grpcio-tools

Generate Attack Protos

# Windows
python -m grpc_tools.protoc `
  -I ./modules/dotnet-grpc-library-api/LibrarySystem.Contracts/Protos `
  --python_out=./attack --grpc_python_out=./attack `
  ./modules/dotnet-grpc-library-api/LibrarySystem.Contracts/Protos/library.proto
# Linux/macOS
python3 -m grpc_tools.protoc \
  -I ./modules/dotnet-grpc-library-api/LibrarySystem.Contracts/Protos \
  --python_out=./attack --grpc_python_out=./attack \
  ./modules/dotnet-grpc-library-api/LibrarySystem.Contracts/Protos/library.proto

Run Exploit Suites

# Target app must be running on localhost:5049
python attack/exploit_xss.py localhost:5049
python attack/exploit_grpc.py localhost:5049

Expected Output:

๐Ÿ“Š XSS Security Report
========================================
Attacks Blocked:  โœ… 7
Bypasses Found:   โŒ 0
False Positives:  โœ… 0

๐Ÿ”ง Troubleshooting

Problem Solution
Submodule not found Run git submodule update --init --recursive
Namespace 'Rasp' not found Open Rasp.sln, not individual .csproj files
gRPC UNAVAILABLE Check target port matches (default: localhost:5049)
Proto files not found Run pip install --upgrade grpcio-tools

๐ŸŽฏ Roadmap

  • Phase 1: Composite solution setup & vulnerability injection
  • Phase 2: gRPC Interceptor with XSS/SQLi detection
  • Phase 3: Source Generator for zero-config integration
  • Phase 4: EF Core Interceptor with SQL analysis ๐Ÿšง
  • Phase 5: Native anti-tamper layer

๐Ÿ“š References


๐Ÿ“œ License

MIT License - Free and open source. See LICENSE for full terms.


๐Ÿ” Found a security issue? See SECURITY.md for responsible disclosure.

โšก Built with .NET 10 | Powered by Clean Architecture