Skip to content

Bug: 8-character hex instance IDs have 32-bit collision risk #129

Description

Summary

short_id() in src/types.rs generates 8-character hex IDs (32 bits of entropy) by taking the last 8 characters of a UUID v4:

pub fn short_id() -> String {
    let uuid = Uuid::new_v4();
    uuid.to_string()
        .chars()
        .rev()
        .take(8)
        .collect::<String>()
        .chars()
        .rev()
        .collect()
}

With ~65,000 instances the birthday paradox gives a 50% collision probability. A collision causes a hard PRIMARY KEY violation on df.instances.id.

Severity

Low-Medium — not silent (PK violation surfaces as an error), but a production system at moderate throughput will hit this within months to years.

Fix

Drop short_id() and use a full UUID (or at minimum 16 hex characters / 64 bits of entropy). Full UUID eliminates the problem entirely and is the simplest fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions