Skip to content

Replace SystemSingleton #2817

@mssalvatore

Description

@mssalvatore

Refactor

Component(s) to be refactored

  • Agent
  • SystemSingleton

Explanation

The Agent tries to avoid having multiple instances of itself running simultaneously on a single machine. To achieve this, it opens an abstract unix socket with a constant name. When another agent attempts to run, it will be unable to open the socket (it's already open) and the agent will exit gracefully.

Unfortunately, this constitutes a low-severity DoS vulnerability. Anyone with access to a target machine can open up an abstract socket with the name that the agent expects. This will prevent any agents from running on the machine.

To resolve this issue, the Island could enforce the rule that only one agent at a time may run on a machine. When the agent starts, it can query the Island to see if any terminate signal has been sent to the agent. The Island can determine if the agent is a duplicate and send it a terminal using the following criteria:

  1. Are there any other agents currently running on the machine?
  2. Do the running agents have an earlier registration time than this agent?

This solution has a very small risk of race conditions. These race conditions are likely to resolve themselves with minimal (if any) impact to the running agents. When the SystemSingleton was introduced, two agents running on the system would interfere with each other. Significant refactoring and redesign has taken place that could allow multiple agents to run simultaneously. Whereas before it was impossible for agents to run simultaneously, now it is simply undesirable.

Tasks

  • Add Agent.registration_time (0d) @cakekoa
  • Modify the agent registration event handler to set Agent.registration_time (0d) @cakekoa
  • Modify the Island's AgentSignalsService to determine whether or not an agent is a duplicate. (0d) @cakekoa
  • Modify the Agent to check for a terminate signal instead of using the SystemSingleton and remove the SystemSingleton (0.25d) @cakekoa

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions