Impostor has an Anticheat that makes it possible to kick cheaters from games automatically. Note that the anticheat is tuned on the vanilla version of the game, so client-side modifications could trigger the Anticheat if you're playing with them.
-| Key | Default | Value |
-|-------------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **Enabled** | `true` | Whether the anticheat should be enabled. |
-| **BanIpFromGame** | `true` | When anticheat is enabled and a player is caught hacking, they will be kicked from the server. If this value is set to `true`, the player will be banned instead and will not be able to rejoin that specific game. |
-| **AllowCheatingHosts** | `"Never"` | Configure whether hosts are allowed to cheat. "Never" forbids it, "Always" allows it. "IfRequested" allows hosts to cheat if they connect with the DisableServerAuthorityFlag set. |
-| **EnableGameFlowChecks** | `true` | Enable checks that check if certain actions are done in the appropriate order or at the appropriate moment in the game. This includes changing cosmetics while in game or murdering too fast. |
-| **EnableInvalidObjectChecks** | `true` | Enables checks that check if network objects are spawned properly. Disabling this option also implies disabling EnableRoleChecks. |
-| **EnableMustBeHostChecks** | `true` | Enables checks that check if players are the host before they can do actions that require them to be host of the game. This includes starting the game and spawning objects. |
-| **EnableColorLimitChecks** | `true` | Enables checks that checks if players request colors that are already in use. |
-| **EnableNameLimitChecks** | `true` | Enables checks that checks if player names have a length that is possible to set using the user interface. |
-| **EnableOwnershipChecks** | `true` | Enables checks that check if players are allowed to perform a certain action on themself or another player. |
-| **EnableRoleChecks** | `true` | Enables checks that check if players have the correct role when performing certain role abilities like venting or murdering. |
-| **EnableTargetChecks** | `true` | Enables checks that check if certain packets to everyone that should only have been sent to certain players or vice versa. This includes sending votes or network objects. |
-| **ForbidProtocolExtensions** | `true` | If disabled allows players to send network packets that go beyond the network packets sent by the vanilla game. This is necessary for most mods that need all players to install it. |
+| Key | Default | Value |
+|-------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| **Enabled** | `true` | Whether the anticheat should be enabled. |
+| **BanIpFromGame** | `true` | When anticheat is enabled and a player is caught hacking, they will be kicked from the server. If this value is set to `true`, the player will be banned instead and will not be able to rejoin that specific game. |
+| **AllowCheatingHosts** | `"Never"` | Configure whether hosts are allowed to cheat. "Never" forbids it, "Always" allows it. "IfRequested" allows hosts to cheat if they connect with the DisableServerAuthorityFlag set. |
+| **AllowHostOnlyExtensions** | "IfRequested" | Configure whether [Host-Only extensions](https://github.com/Innersloth-LLC/AmongUsModdingInformation#host-only-mods) are allowed in all games ("Always"), +25 games only ("IfRequested") or by nobody ("Never") |
+| **EnableGameFlowChecks** | `true` | Enable checks that check if certain actions are done in the appropriate order or at the appropriate moment in the game. This includes changing cosmetics while in game or murdering too fast. |
+| **EnableInvalidObjectChecks** | `true` | Enables checks that check if network objects are spawned properly. Disabling this option also implies disabling EnableRoleChecks. |
+| **EnableMustBeHostChecks** | `true` | Enables checks that check if players are the host before they can do actions that require them to be host of the game. This includes starting the game and spawning objects. |
+| **EnableColorLimitChecks** | `true` | Enables checks that checks if players request colors that are already in use. |
+| **EnableNameLimitChecks** | `true` | Enables checks that checks if player names have a length that is possible to set using the user interface. |
+| **EnableOwnershipChecks** | `true` | Enables checks that check if players are allowed to perform a certain action on themself or another player. |
+| **EnableRoleChecks** | `true` | Enables checks that check if players have the correct role when performing certain role abilities like venting or murdering. |
+| **EnableTargetChecks** | `true` | Enables checks that check if certain packets to everyone that should only have been sent to certain players or vice versa. This includes sending votes or network objects. |
+| **ForbidProtocolExtensions** | `true` | If disabled allows players to send network packets that go beyond the network packets sent by the vanilla game. This is necessary for most mods that need all players to install it. |
### Compatibility
/// <summary>A packet used a part of the network protocol that is unknown to Impostor, like a custom RPC.</summary>
ProtocolExtension,
+ /// <summary>A host-only mod extension is used outside of host-authoritive mode.</summary>
+ HostOnlyExtension,
+
/// <summary>A packet was sent at an inappropriate moment.</summary>
GameFlow,
public CheatingHostMode AllowCheatingHosts { get; set; } = CheatingHostMode.Never;
+ public CheatingHostMode AllowHostOnlyExtensions { get; set; } = CheatingHostMode.IfRequested;
+
public bool EnableGameFlowChecks { get; set; } = true;
public bool EnableMustBeHostChecks { get; set; } = true;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Reflection;
.ToDictionary(x => (byte)x.GetValue(null)!, y => y.Name);
}
+ /// <summary>
+ /// Convert a MessageFlag to the corresponding string.
+ /// </summary>
+ /// <param name="flag">The MessageFlag to convert.</param>
+ /// <returns>A string corresponding with the value of flag.</returns>
public static string FlagToString(byte flag)
{
return FlagCache.TryGetValue(flag, out var res) ? res : $"Unknown Flag {flag}";
CheatCategory.Ownership => _antiCheatConfig.EnableOwnershipChecks,
CheatCategory.Role => _antiCheatConfig.EnableRoleChecks,
CheatCategory.Target => _antiCheatConfig.EnableTargetChecks,
+ CheatCategory.HostOnlyExtension => _antiCheatConfig.AllowHostOnlyExtensions switch {
+ CheatingHostMode.Always => false,
+ CheatingHostMode.IfRequested => !GameVersion.HasDisableServerAuthorityFlag,
+ CheatingHostMode.Never => true,
+ _ => true,
+ },
CheatCategory.Other => true,
_ => LogUnknownCategory(category),
};
case MessageFlags.StartGame:
{
- if (!IsPacketAllowed(reader, true))
+ if (!IsPacketAllowed(reader, true, flag))
{
return;
}
case MessageFlags.RemovePlayer:
{
- if (!IsPacketAllowed(reader, true))
+ if (!IsPacketAllowed(reader, true, flag))
{
return;
}
case MessageFlags.GameData:
case MessageFlags.GameDataTo:
{
- if (!IsPacketAllowed(reader, false))
+ if (!IsPacketAllowed(reader, false, flag))
{
return;
}
case MessageFlags.PackedGameDataTo:
{
- if (!IsPackedGameDataToAllowed(reader))
+ // We're limiting this to hosts right now. If you have a use case for this for
+ // players to use this feature, we're open to changing this.
+ if (!IsPacketAllowed(reader, true, flag))
+ {
+ return;
+ }
+
+ if (await ReportCheatAsync(
+ new CheatContext(MessageFlags.FlagToString(flag)),
+ CheatCategory.HostOnlyExtension,
+ "Client sent a PackedGameDataTo message"))
{
return;
}
case MessageFlags.EndGame:
{
- if (!IsPacketAllowed(reader, true))
+ if (!IsPacketAllowed(reader, true, flag))
{
return;
}
case MessageFlags.AlterGame:
{
- if (!IsPacketAllowed(reader, true))
+ if (!IsPacketAllowed(reader, true, flag))
{
return;
}
case MessageFlags.KickPlayer:
{
- if (!IsPacketAllowed(reader, true))
+ if (!IsPacketAllowed(reader, true, flag))
{
return;
}
await _gameManager.OnClientDisconnectAsync(this);
}
- private bool IsPacketAllowed(IMessageReader message, bool hostOnly)
+ private bool IsPacketAllowed(IMessageReader message, bool hostOnly, byte flag)
{
if (Player == null)
{
return true;
}
- _logger.LogWarning("[{0}] Client sent packet only allowed by the host ({1}).", Id, game.HostId);
+ _logger.LogWarning(
+ "[{0}] Client sent packet {1} only allowed by the host ({2}).",
+ Id,
+ MessageFlags.FlagToString(flag),
+ game.HostId);
return false;
}
return true;
}
- private bool IsPackedGameDataToAllowed(IMessageReader message)
- {
- if (Player == null)
- {
- return false;
- }
-
- var game = Player.Game;
-
- if (message.ReadPackedInt32() != game.Code)
- {
- return false;
- }
-
- if (game.HostId == Id)
- {
- return true;
- }
-
- _logger.LogWarning("[{0}] Client sent PackedGameDataTo only allowed by the host ({1}).", Id, game.HostId);
- return false;
- }
-
/// <summary>
/// Triggered when the connected client requests the PlatformSpecificData.
/// </summary>