use std::time::Duration;
use evalbox_sandbox::{Executor, Plan};
use crate::common::{SIGSYS, payload};
#[test]
#[ignore]
fn test_cve_2024_1086_nftables_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("cve_2024_1086_nftables"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"CVE-2024-1086 attack vector should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_cve_2022_0185_fsconfig_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("cve_2022_0185_fsconfig"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success(),
"CVE-2022-0185 attack vector should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_cve_2017_5226_tiocsti_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("cve_2017_5226_tiocsti"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"TIOCSTI should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_cve_2022_0492_cgroups_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("cve_2022_0492_cgroups"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"CVE-2022-0492 attack should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_fileless_memfd_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("fileless_memfd"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"Fileless execution should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_ioctl_tioclinux_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("ioctl_tioclinux"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"TIOCLINUX should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_ioctl_tiocsetd_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("ioctl_tiocsetd"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"TIOCSETD should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_userns_creation_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("userns_escape"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"User namespace creation should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_ptrace_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("ptrace_escape"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"ptrace should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}
#[test]
#[ignore]
fn test_cve_2019_10063_ioctl_bypass_blocked() {
let output = Executor::run(
Plan::new(["./payload"])
.executable("payload", payload("cve_2019_10063_ioctl_bypass"))
.binary_path("./payload")
.timeout(Duration::from_secs(5)),
)
.expect("Executor should run");
assert!(
!output.success() || output.signal == Some(SIGSYS),
"CVE-2019-10063 ioctl bypass should be blocked. Exit: {:?}, Signal: {:?}",
output.exit_code,
output.signal
);
}