Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Assets/Mirror/Core/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ public bool authority
// hook guard prevents that.
ulong syncVarHookGuard;

// [Command(requiresAuthority=false)] on global objects allow any sender.
// senders can be verified with optional (NetworkConnectionToClient) parameter.
// if a studio forgot to add that parameter, then validating senders would requires a full server + client rebuild.
// sometimes that's not possible in time (i.e. urgent exploits), in that case - this field can be used.
protected NetworkConnectionToClient lastCommandSender = null;
internal void SetLastCommandSender(NetworkConnectionToClient conn) => lastCommandSender = conn;

protected virtual void OnValidate()
{
// Skip if Editor is in Play mode
Expand Down
3 changes: 3 additions & 0 deletions Assets/Mirror/Core/RemoteCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ internal static bool Invoke(ushort functionHash, RemoteCallType remoteCallType,
if (GetInvokerForHash(functionHash, remoteCallType, out Invoker invoker) &&
invoker.componentType.IsInstanceOfType(component))
{
// set sender in case it's needed
component.SetLastCommandSender(senderConnection);

// invoke function on this component
invoker.function(component, reader, senderConnection);
return true;
Expand Down