Files
opengenesislinkserver/OpenSim/Framework/AssetPermissions.cs
T
OpenGenesis (MPL 2.0) 830964c74b security(gen1): block public Hypergrid asset egress while preserving local rendering (#328)
* security(gen1): block all outbound HG asset reads and metadata when export lockdown enabled

* security(gen1): block all outbound HG asset reads and metadata when export lockdown enabled

* security(gen1): block all outbound HG asset reads and metadata when export lockdown enabled

* security(gen1): block all outbound HG asset reads and metadata when export lockdown enabled

* security(gen1): disable outbound Hypergrid inventory transfers in operator profile

* security(gen1): introduce type-independent Hypergrid export lock

* fix(gen1): keep single export policy declaration and guard

* security(gen1): deny public HG asset reads, cached reads and metadata in full lockdown

* security(gen1): deny outbound Hypergrid asset reads in bin/Robust.HG.ini

* security(gen1): deny outbound Hypergrid asset reads in bin/Robust.HG.ini.example

* security(gen1): deny outbound Hypergrid asset reads in bin/Robust.HG.OGLAsset.ini.example

* security(gen1): deny outbound Hypergrid asset reads in bin/config-include/GridCommon.ini

* security(gen1): deny outbound Hypergrid asset reads in bin/config-include/GridCommon.ini.example

* security(gen1): deny outbound Hypergrid asset reads in bin/config-include/StandaloneCommon.ini.example

* docs(gen1): scope HG export lockdown and document Copybot threat-model limits

* test(gen1): assert complete outbound HG asset lockdown coverage in CI

* ci(gen1): verify HG outbound asset lockdown before runtime smoke tests
2026-10-28 13:34:35 +01:00

94 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using log4net;
using OpenMetaverse;
namespace OpenSim.Framework
{
public class AssetPermissions
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private bool[] m_DisallowExport, m_DisallowImport;
private readonly bool m_BlockAllExports;
// Applies to the public Hypergrid service only when explicitly configured.
// All asset types, including future/unknown ones, are blocked.
public bool BlockAllExports => m_BlockAllExports;
private string[] m_AssetTypeNames;
public AssetPermissions(IConfig config)
{
Type enumType = typeof(AssetType);
m_AssetTypeNames = Enum.GetNames(enumType);
for (int i = 0; i < m_AssetTypeNames.Length; i++)
m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower();
int n = Enum.GetValues(enumType).Length;
m_DisallowExport = new bool[n];
m_DisallowImport = new bool[n];
m_BlockAllExports = config != null && config.GetBoolean("DisallowAllExport", false);
LoadPermsFromConfig(config, "DisallowExport", m_DisallowExport);
LoadPermsFromConfig(config, "DisallowImport", m_DisallowImport);
}
private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray)
{
if (assetConfig == null)
return;
string perms = assetConfig.GetString(variable, String.Empty);
string[] parts = perms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in parts)
{
int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower());
if (index >= 0)
bitArray[index] = true;
else
m_log.Warn($"[Asset Permissions]: Invalid AssetType {s}");
}
}
public bool AllowedExport(sbyte type)
{
if (m_BlockAllExports)
return false;
string assetTypeName = ((AssetType)type).ToString();
int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
if (index >= 0 && m_DisallowExport[index])
{
m_log.Debug($"[Asset Permissions]: Export denied: configuration does not allow export of AssetType {assetTypeName}");
return false;
}
return true;
}
public bool AllowedImport(sbyte type)
{
string assetTypeName = ((AssetType)type).ToString();
int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
if (index >= 0 && m_DisallowImport[index])
{
m_log.Debug($"[Asset Permissions]: Import denied: configuration does not allow import of AssetType {assetTypeName}");
return false;
}
return true;
}
}
}