fix(net10/security): disable unsafe BinaryFormatter opt-ins in prebuild and all shipped runtimes
This commit is contained in:
1 parent
43e101f737
commit
3d5fe72c85
12 files changed
+67
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Ensure .NET 10 YEngine and generic helpers never activate BinaryFormatter."""
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
y = (ROOT / "OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs").read_text()
|
||||
@@ -27,4 +28,20 @@ assert "ReadPersistedStateXmlFile(m_StateFileName)" in ctor
|
||||
assert "WriteStateFileAtomically(m_StateFileName, scriptStateN.OuterXml)" in capture
|
||||
assert "DtdProcessing = DtdProcessing.Prohibit" in capture
|
||||
assert "File.Move(temporary, statePath, overwrite: true)" in capture
|
||||
print("PASS: no BinaryFormatter activation in YEngine or Util, legacy state preserved")
|
||||
generator = (ROOT / "Prebuild/src/Core/Targets/VSGenericTarget.cs").read_text()
|
||||
assert '<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>' in generator
|
||||
assert '<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>' not in generator
|
||||
retarget = (ROOT / "tools/gen11/retarget_net10.py").read_text()
|
||||
assert "UNSAFE_TRUE" in retarget and "UNSAFE_FALSE" in retarget
|
||||
assert 'converted = source.replace(OLD, NEW).replace(UNSAFE_TRUE, UNSAFE_FALSE)' in retarget
|
||||
runtime_paths = [
|
||||
ROOT / "OpenSim/Server/runtimeconfig.template.json",
|
||||
ROOT / "OpenSim/Region/Application/runtimeconfig.template.json",
|
||||
*sorted((ROOT / "bin").glob("*.runtimeconfig.json")),
|
||||
]
|
||||
for runtime_path in runtime_paths:
|
||||
config = json.loads(runtime_path.read_text())
|
||||
enabled = config["runtimeOptions"].get("configProperties", {}).get(
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization", False)
|
||||
assert enabled is not True, f"Unsafe BinaryFormatter runtime opt-in: {runtime_path}"
|
||||
print("PASS: no BinaryFormatter activation, unsafe build opt-ins or runtime opt-ins; state preserved")
|
||||
Reference in new issue
Block a user