// [CRUCIBLE-SEED] // category: path_traversal // severity: high // language: csharp // expected: Path traversal in file delete via Directory.Delete with user-controlled path using System.IO; using Microsoft.AspNetCore.Mvc; namespace App.Controllers { [ApiController] [Route("api/[controller]")] public class CleanupController : ControllerBase { private const string UploadRoot = "/var/uploads/"; [HttpDelete] public IActionResult DeleteFile([FromQuery] string relativePath) { // Vulnerable: relativePath with ../ can delete files outside UploadRoot string fullPath = Path.Combine(UploadRoot, relativePath); if (Directory.Exists(fullPath)) Directory.Delete(fullPath, recursive: true); else if (File.Exists(fullPath)) File.Delete(fullPath); return Ok("Deleted"); } } }