Summary
When compiling a .cs_net7 submission, the ECS runner auto-generates a project file that includes <AllowUnsafeBlocks>true</AllowUnsafeBlocks>. This enables unsafe code in all submitted C# solutions without restriction.
Affected File
ecs-runner/src/main/java/com/topcoder/runner/EcsRunnerMain.java, lines 3288–3301
Files.write(csproj, Arrays.asList(
"<Project Sdk=\"Microsoft.NET.Sdk\">",
" <PropertyGroup>",
" <TargetFramework>net7.0</TargetFramework>",
" <OutputType>Exe</OutputType>",
" <AllowUnsafeBlocks>true</AllowUnsafeBlocks>", // ← here
" </PropertyGroup>",
"</Project>"
), StandardCharsets.UTF_8);
Impact
With unsafe enabled, a C# submission can:
- Use raw pointer arithmetic — allows reading/writing arbitrary memory addresses within the process
- Call native code via P/Invoke — combined with unsafe blocks, the submission can invoke
open, read, mmap, and other native syscalls that are not blocked by the seccomp filter (which only blocks socket() and socketpair())
- Enumerate
/proc filesystem via native opendir/readdir calls without triggering any seccomp rule
- Read other files in the container (
/tmp/mm-isolated-scorer-*.json, /tmp/tester-*.jar, etc.) using native file I/O even if managed I/O were somehow restricted
The seccomp filter in mm-net-isolate.c only blocks network socket creation. Enabling unsafe C# code opens a direct path to all other OS-level operations.
Expected
Remove <AllowUnsafeBlocks>true</AllowUnsafeBlocks> from the generated project file. Competitive programming problems do not require unsafe memory access. If a specific challenge needs it, it should be an explicit opt-in configured per-challenge rather than a global default.
Severity: Medium
Summary
When compiling a
.cs_net7submission, the ECS runner auto-generates a project file that includes<AllowUnsafeBlocks>true</AllowUnsafeBlocks>. This enablesunsafecode in all submitted C# solutions without restriction.Affected File
ecs-runner/src/main/java/com/topcoder/runner/EcsRunnerMain.java, lines 3288–3301Impact
With
unsafeenabled, a C# submission can:open,read,mmap, and other native syscalls that are not blocked by the seccomp filter (which only blockssocket()andsocketpair())/procfilesystem via nativeopendir/readdircalls without triggering any seccomp rule/tmp/mm-isolated-scorer-*.json,/tmp/tester-*.jar, etc.) using native file I/O even if managed I/O were somehow restrictedThe seccomp filter in
mm-net-isolate.conly blocks network socket creation. Enabling unsafe C# code opens a direct path to all other OS-level operations.Expected
Remove
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>from the generated project file. Competitive programming problems do not require unsafe memory access. If a specific challenge needs it, it should be an explicit opt-in configured per-challenge rather than a global default.Severity: Medium