Security: WS-Rollenprüfung, JWT-Cookie statt localStorage, XSS/SSRF-Fixes, RDP-Consent-Secret
- WebSocket Shell/RDP: Rollenprüfung statt nur JWT-Gültigkeit (war: jeder eingeloggte User konnte fremde Agents per Shell/RDP übernehmen) - JWT_SECRET: Server bricht ab statt mit unsicherem Default weiterzulaufen - Auth: Token läuft jetzt über httpOnly-Cookie statt localStorage (XSS-Schutz gegen Session-Diebstahl) - WS-Auth: Token nicht mehr als URL-Query-Param (landete in nginx-Logs), sondern als erste Message bzw. automatisch via Cookie - Frontend: toter Rollen-Check (isSuperAdmin/isAdmin ohne Funktionsaufruf) in AgentDetailPage gefixt - XSS: DOMPurify-Sanitizing für alle marked.parse()-Renderstellen (KI-Antworten, Kommentare, Knowledge Base) - E-Mail: HTML-Escaping für alle ticket-gesteuerten Felder (auch über öffentliche Ticket-Route erreichbar) - SSRF-Schutz beim Knowledge-Base-URL-Import (blockt private/Loopback-Adressen) - TV-Dashboard: Shared-Key statt komplett offenem Endpoint - Striktes Rate-Limit auf /login, must_change_password serverseitig erzwungen - Agent (C#) v2.7.0: RDP-Consent/Disconnect/Capture verlangen jetzt ein Pro-Session-Secret (war: jeder lokale Prozess konnte Consent vortäuschen), DataDir-ACL für agent.log/status.json - FIDO-PINs AES-256-GCM-verschlüsselt statt Klartext, Retention-Job für alte patch_commands/audit_log Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ namespace ITNexusAgent;
|
||||
|
||||
public class AgentWorker
|
||||
{
|
||||
private const string Version = "2.6.0";
|
||||
private const string Version = "2.7.0";
|
||||
private const string DataDir = @"C:\ProgramData\IT Nexus Agent";
|
||||
private const string ConfigPath = @"C:\ProgramData\IT Nexus Agent\config.json";
|
||||
private const string StatusPath = @"C:\ProgramData\IT Nexus Agent\status.json";
|
||||
@@ -24,6 +24,7 @@ public class AgentWorker
|
||||
{
|
||||
_exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
||||
Directory.CreateDirectory(DataDir);
|
||||
SecureDataDir(DataDir);
|
||||
|
||||
if (!File.Exists(ConfigPath))
|
||||
{
|
||||
@@ -176,6 +177,30 @@ public class AgentWorker
|
||||
catch { }
|
||||
}
|
||||
|
||||
// Verzeichnis-ACL: nur SYSTEM/Administratoren — verhindert dass normale lokale User
|
||||
// agent.log/status.json lesen (Hostname, letzter User, RDP-/Patch-Aktivität) oder manipulieren.
|
||||
private static void SecureDataDir(string dir)
|
||||
{
|
||||
try
|
||||
{
|
||||
var di = new System.IO.DirectoryInfo(dir);
|
||||
var acl = di.GetAccessControl();
|
||||
acl.SetAccessRuleProtection(true, false);
|
||||
acl.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(
|
||||
"SYSTEM", System.Security.AccessControl.FileSystemRights.FullControl,
|
||||
System.Security.AccessControl.InheritanceFlags.ContainerInherit | System.Security.AccessControl.InheritanceFlags.ObjectInherit,
|
||||
System.Security.AccessControl.PropagationFlags.None,
|
||||
System.Security.AccessControl.AccessControlType.Allow));
|
||||
acl.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(
|
||||
"Administrators", System.Security.AccessControl.FileSystemRights.FullControl,
|
||||
System.Security.AccessControl.InheritanceFlags.ContainerInherit | System.Security.AccessControl.InheritanceFlags.ObjectInherit,
|
||||
System.Security.AccessControl.PropagationFlags.None,
|
||||
System.Security.AccessControl.AccessControlType.Allow));
|
||||
di.SetAccessControl(acl);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void SecureConfigFile(string path)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user