SDT0602: RPC Validation Method Missing

Property Value
Rule ID SDT0602
Title RPC Validation Method Missing
Category Network
Severity Error

Cause

An RPC method expects a corresponding validation method, but the given validation method cannot be found within the same class.

Rule Description

To protect the server from malicious client inputs, it is recommended to specify a verification companion method. When defining the validation method with Validation=, the method MUST exist

How to Fix Violations

Implement the missing validation method, or provide the correct name in the same class.

Violation:

[RPC(PacketBroadcast.Client, Validation="RPC_SetPlayerGold_Validate")]
public void RPC_SetPlayerGold(int amount) 
{
    // Implementation
}
// Missing: bool RPC_SetPlayerGold_Validate(int amount)

bool RPC_SetPlayerGold_Val(int amount) 
{
    return amount >= 0 && amount <= 10000;
}

Fix:

[RPC(PacketBroadcast.Client, Validation=nameof(RPC_SetPlayerGold_Val))]
public void RPC_SetPlayerGold(int amount) 
{
    // Implementation
}

bool RPC_SetPlayerGold_Val(int amount) 
{
    return amount >= 0 && amount <= 10000;
}

When to Suppress Warnings

Danger

Do not suppress this error. When specifying an explicit validation method, it must exist.