Matrix/Deploy/SDF-DP02

SDF-DP02

Canary Token Distribution

foundationalDetection Value: criticalCost: minimalTime: 1-3 days📄 Data & Documents

Description

Distribute canary tokens across strategic locations throughout the environment. Canary tokens are lightweight tripwires embedded in files, URLs, DNS records, or credentials that generate an alert when accessed, without requiring any infrastructure beyond a callback server.

Rationale

Canary tokens can provide lightweight monitoring without the infrastructure required by interactive honeypots. They may be placed in documents, DNS records, configuration files, or database records. Alerts can be low-noise when legitimate access paths are excluded, but authorized testing, scanners, and accidental contact must still be considered.

Supporting Basis

Direct antecedent

Honeyfiles, monitored credentials, beacons, and honeytokens are deployed so their access or use can raise an alert.

These sources establish design lineage and scope. They do not validate this record's operational effectiveness, planning estimates, environment labels, or ATT&CK relationships.

Implementation Steps

1

Select canary token types

Choose from available token types: DNS tokens, HTTP tokens, document tokens (Word, PDF, Excel), AWS key tokens, email tokens, or custom tokens.

2

Generate tokens

Create unique tokens for each placement location. Ensure each token can be independently identified when triggered so you know exactly which asset was accessed.

3

Place tokens strategically

Distribute tokens in locations where adversaries forage: shared drives, configuration files, browser bookmark files, environment variables, and cloud storage buckets.

4

Configure alert routing

Set up alert delivery for token triggers. Include webhook integrations to push alerts to SOC communication channels in real time.

5

Create token inventory

Maintain a registry of all deployed tokens, their locations, types, and expected alert behavior. This inventory is essential for managing token lifecycle.

Technical Implementation Examples(1)

Canary Token Generator Script

Python script to generate various types of canary tokens and maintain a deployment inventory

python
"""
Canary Token Generator and Inventory Manager.
Generates DNS, HTTP, and document-based canary tokens and
maintains a registry of deployed tokens for alert correlation.
"""
import json
import uuid
import hashlib
import os
from datetime import datetime
from typing import Dict, List

INVENTORY_FILE = "canary_inventory.json"
CALLBACK_DOMAIN = "tokens.shadow-cdf.internal"

class CanaryTokenManager:
    def __init__(self):
        self.inventory: List[Dict] = []
        self._load_inventory()

    def _load_inventory(self):
        if os.path.exists(INVENTORY_FILE):
            with open(INVENTORY_FILE) as f:
                self.inventory = json.load(f)

    def _save_inventory(self):
        with open(INVENTORY_FILE, "w") as f:
            json.dump(self.inventory, f, indent=2)

    def _generate_token_id(self) -> str:
        return hashlib.sha256(
            uuid.uuid4().bytes
        ).hexdigest()[:16]

    def create_dns_token(
        self, placement: str, description: str
    ) -> Dict:
        """Create a DNS-based canary token.
        Triggers when the hostname is resolved."""
        token_id = self._generate_token_id()
        hostname = f"{token_id}.{CALLBACK_DOMAIN}"

        token = {
            "type": "dns",
            "token_id": token_id,
            "trigger_value": hostname,
            "placement": placement,
            "description": description,
            "created_at": datetime.utcnow().isoformat(),
            "status": "active",
            "alert_message": f"DNS canary triggered: "
                             f"{placement} - {description}",
        }
        self.inventory.append(token)
        self._save_inventory()
        return token

    def create_http_token(
        self, placement: str, description: str
    ) -> Dict:
        """Create an HTTP-based canary token.
        Triggers when the URL is fetched."""
        token_id = self._generate_token_id()
        url = f"https://{CALLBACK_DOMAIN}/t/{token_id}/logo.png"

        token = {
            "type": "http",
            "token_id": token_id,
            "trigger_value": url,
            "placement": placement,
            "description": description,
            "embed_html": f'<img src="{url}" width="1" '
                          f'height="1" alt="" />',
            "created_at": datetime.utcnow().isoformat(),
            "status": "active",
        }
        self.inventory.append(token)
        self._save_inventory()
        return token

    def create_credential_token(
        self, username: str, password: str,
        placement: str, description: str,
    ) -> Dict:
        """Create a credential-based canary.
        Triggers when username/password is used for authentication."""
        token_id = self._generate_token_id()

        token = {
            "type": "credential",
            "token_id": token_id,
            "trigger_value": {
                "username": username,
                "password_hash": hashlib.sha256(
                    password.encode()
                ).hexdigest(),
            },
            "placement": placement,
            "description": description,
            "created_at": datetime.utcnow().isoformat(),
            "status": "active",
            "siem_query": f'event.action:"authentication" AND '
                          f'user.name:"{username}"',
        }
        self.inventory.append(token)
        self._save_inventory()
        return token

    def print_inventory_summary(self):
        print(f"\nCanary Token Inventory: {len(self.inventory)} tokens")
        print("-" * 60)
        for token in self.inventory:
            print(f"  [{token['type']:12s}] {token['token_id']}")
            print(f"    Placement: {token['placement']}")
            print(f"    Status:    {token['status']}")
            print()

if __name__ == "__main__":
    mgr = CanaryTokenManager()

    # Deploy tokens across the environment
    mgr.create_dns_token(
        placement="/opt/app/config/monitoring.conf",
        description="Fake monitoring endpoint in app config",
    )
    mgr.create_http_token(
        placement="IT_Network_Diagram_2026.docx",
        description="Tracking pixel in decoy network diagram",
    )
    mgr.create_credential_token(
        username="svc_sql_backup",
        password="SqlB4ckup#Pr0d!",
        placement="backup-config.sh on file-server-02",
        description="Trap DB credentials in backup script",
    )

    mgr.print_inventory_summary()

MITRE ATT&CK Mappings

TechniqueTacticRelationship
T1083File and Directory DiscoveryDiscoverydetects
T1005Data from Local SystemCollectiondetects
T1552Unsecured CredentialsCredential Accessdetects

Considerations

  • Canary tokens should have filenames and locations that make them attractive to adversaries. A file named "passwords.xlsx" on a shared drive is more likely to be opened than "test_document.txt".
  • Rotate tokens periodically to prevent adversaries who have mapped your deception from avoiding known tokens.
  • Test token triggering regularly to ensure the callback mechanism remains operational.

Supported Environments

🏢On-Premise
☁Amazon Web Services
☁Microsoft Azure
☁Google Cloud Platform
🔄Hybrid Environment
🏭OT/ICS Environment

Tools & Resources

  • Canarytokens.org (free canary token service)
  • Thinkst Canary (commercial canary platform)
  • Custom canary token implementations
  • Webhook integration platforms

Quick Stats

Phase
Deploy
Difficulty
foundational
Detection Value
critical
Cost
minimal
Time
1-3 days
ATT&CK Mappings
3