mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-12 19:55:14 +02:00
[pitboss] phase 17: Track L.15 — Gin / Echo / Fiber / Chi adapters + Axum / Actix / Rocket / Warp adapters
This commit is contained in:
parent
5393fe22f2
commit
2b96c6005b
33 changed files with 3247 additions and 27 deletions
19
tests/dynamic_fixtures/rust_frameworks/actix/benign.rs
Normal file
19
tests/dynamic_fixtures/rust_frameworks/actix/benign.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Phase 17 (Track L.15) — actix-web benign control fixture.
|
||||
|
||||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use serde::Deserialize;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
#[get("/run")]
|
||||
pub async fn run(q: web::Query<RunQuery>) -> impl Responder {
|
||||
let allow = ["ls", "ps"];
|
||||
if allow.contains(&q.cmd.as_str()) {
|
||||
let _ = Command::new(&q.cmd).status();
|
||||
}
|
||||
HttpResponse::Ok().body("ok")
|
||||
}
|
||||
20
tests/dynamic_fixtures/rust_frameworks/actix/vuln.rs
Normal file
20
tests/dynamic_fixtures/rust_frameworks/actix/vuln.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
//! Phase 17 (Track L.15) — actix-web CMDI vuln fixture.
|
||||
//!
|
||||
//! The /run route forwards a `cmd` query parameter straight into
|
||||
//! `std::process::Command`. Adapter binding: `#[get("/run")]` on
|
||||
//! `run` with `cmd` arriving via `web::Query<RunQuery>`.
|
||||
|
||||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use serde::Deserialize;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
#[get("/run")]
|
||||
pub async fn run(q: web::Query<RunQuery>) -> impl Responder {
|
||||
let _ = Command::new("sh").arg("-c").arg(&q.cmd).status();
|
||||
HttpResponse::Ok().body("ok")
|
||||
}
|
||||
27
tests/dynamic_fixtures/rust_frameworks/axum/benign.rs
Normal file
27
tests/dynamic_fixtures/rust_frameworks/axum/benign.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//! Phase 17 (Track L.15) — axum benign control fixture.
|
||||
//!
|
||||
//! The /run route allow-lists the `cmd` value before invoking
|
||||
//! `std::process::Command`, so attacker bytes never reach the sink.
|
||||
|
||||
use axum::extract::Query;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use serde::Deserialize;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
pub async fn run(Query(q): Query<RunQuery>) -> String {
|
||||
let allow = ["ls", "ps"];
|
||||
if allow.contains(&q.cmd.as_str()) {
|
||||
let _ = Command::new(&q.cmd).status();
|
||||
}
|
||||
"ok".to_owned()
|
||||
}
|
||||
|
||||
pub fn build() -> Router {
|
||||
Router::new().route("/run", get(run))
|
||||
}
|
||||
26
tests/dynamic_fixtures/rust_frameworks/axum/vuln.rs
Normal file
26
tests/dynamic_fixtures/rust_frameworks/axum/vuln.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//! Phase 17 (Track L.15) — axum CMDI vuln fixture.
|
||||
//!
|
||||
//! The /run route forwards a `cmd` query parameter straight into
|
||||
//! `std::process::Command`. Adapter binding:
|
||||
//! `Router::new().route("/run", get(run))` with `cmd` arriving via
|
||||
//! `axum::extract::Query<RunQuery>`.
|
||||
|
||||
use axum::extract::Query;
|
||||
use axum::Router;
|
||||
use axum::routing::get;
|
||||
use serde::Deserialize;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
pub async fn run(Query(q): Query<RunQuery>) -> String {
|
||||
let _ = Command::new("sh").arg("-c").arg(&q.cmd).status();
|
||||
"ok".to_owned()
|
||||
}
|
||||
|
||||
pub fn build() -> Router {
|
||||
Router::new().route("/run", get(run))
|
||||
}
|
||||
13
tests/dynamic_fixtures/rust_frameworks/rocket/benign.rs
Normal file
13
tests/dynamic_fixtures/rust_frameworks/rocket/benign.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
//! Phase 17 (Track L.15) — rocket benign control fixture.
|
||||
|
||||
use rocket::get;
|
||||
use std::process::Command;
|
||||
|
||||
#[get("/run?<cmd>")]
|
||||
pub fn run(cmd: String) -> &'static str {
|
||||
let allow = ["ls", "ps"];
|
||||
if allow.contains(&cmd.as_str()) {
|
||||
let _ = Command::new(&cmd).status();
|
||||
}
|
||||
"ok"
|
||||
}
|
||||
14
tests/dynamic_fixtures/rust_frameworks/rocket/vuln.rs
Normal file
14
tests/dynamic_fixtures/rust_frameworks/rocket/vuln.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//! Phase 17 (Track L.15) — rocket CMDI vuln fixture.
|
||||
//!
|
||||
//! The /run route forwards a `cmd` query parameter straight into
|
||||
//! `std::process::Command`. Adapter binding: `#[get("/run?<cmd>")]`
|
||||
//! on `run` with `cmd` arriving via the function's positional arg.
|
||||
|
||||
use rocket::get;
|
||||
use std::process::Command;
|
||||
|
||||
#[get("/run?<cmd>")]
|
||||
pub fn run(cmd: String) -> &'static str {
|
||||
let _ = Command::new("sh").arg("-c").arg(&cmd).status();
|
||||
"ok"
|
||||
}
|
||||
24
tests/dynamic_fixtures/rust_frameworks/warp/benign.rs
Normal file
24
tests/dynamic_fixtures/rust_frameworks/warp/benign.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//! Phase 17 (Track L.15) — warp benign control fixture.
|
||||
|
||||
use std::process::Command;
|
||||
use serde::Deserialize;
|
||||
use warp::Filter;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
pub fn run(q: RunQuery) -> &'static str {
|
||||
let allow = ["ls", "ps"];
|
||||
if allow.contains(&q.cmd.as_str()) {
|
||||
let _ = Command::new(&q.cmd).status();
|
||||
}
|
||||
"ok"
|
||||
}
|
||||
|
||||
pub fn build() -> impl Filter<Extract = (&'static str,), Error = warp::Rejection> + Clone {
|
||||
warp::path!("run")
|
||||
.and(warp::query::<RunQuery>())
|
||||
.map(run)
|
||||
}
|
||||
26
tests/dynamic_fixtures/rust_frameworks/warp/vuln.rs
Normal file
26
tests/dynamic_fixtures/rust_frameworks/warp/vuln.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//! Phase 17 (Track L.15) — warp CMDI vuln fixture.
|
||||
//!
|
||||
//! The /run filter forwards a query parameter straight into
|
||||
//! `std::process::Command`. Adapter binding:
|
||||
//! `warp::path!("run").and(warp::query::<RunQuery>()).map(run)` with
|
||||
//! `cmd` arriving via warp's typed query.
|
||||
|
||||
use std::process::Command;
|
||||
use serde::Deserialize;
|
||||
use warp::Filter;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RunQuery {
|
||||
pub cmd: String,
|
||||
}
|
||||
|
||||
pub fn run(q: RunQuery) -> &'static str {
|
||||
let _ = Command::new("sh").arg("-c").arg(&q.cmd).status();
|
||||
"ok"
|
||||
}
|
||||
|
||||
pub fn build() -> impl Filter<Extract = (&'static str,), Error = warp::Rejection> + Clone {
|
||||
warp::path!("run")
|
||||
.and(warp::query::<RunQuery>())
|
||||
.map(run)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue