Skip to content

Canadian Social Insurance Numbers (SIN)

Filter

This filter identifies values in the form of Canadian Social Insurance Numbers (SIN) and reports them with the span type canada-sin. A SIN is nine digits, unformatted (046454286) or in three groups of three (046-454-286, 046 454 286).

Every value must pass the Luhn (mod 10) check that SINs carry, which reduces false positives; there is no option to turn it off. SINs beginning with 9, which are issued to temporary residents, are reported like any other.

Canada Revenue Agency business numbers also pass the Luhn check on their nine-digit root, so they are reported as SINs unless onlyValidPrefixes is true, which drops values beginning with 0 or 8.

An unformatted nine-digit value can match both this filter and the SSN filter when both are enabled. It is then reported as one of the two types, canada-sin or ssn, and which one is not fixed. If that matters, give both filters the same strategy, or enable only the one you need. Hyphenated values do not collide, since a SIN is grouped NNN-NNN-NNN and an SSN NNN-NN-NNNN.

Detection is based on the format of the value and the Luhn check, so a nine-digit number that is not a SIN can be reported. Validate the results against your own documents.

Separators and line breaks

Between digit groups the filter accepts a hyphen, a single space or other horizontal whitespace character, or nothing at all. In place of the ASCII hyphen it also accepts the soft hyphen (U+00AD), the dashes U+2010 through U+2015, the minus sign (U+2212), and the small and fullwidth hyphen-minus forms (U+FE58, U+FE63, U+FF0D). A value wrapped across a line break is detected when the break follows a hyphen, such as 046-454- at the end of one line followed by 286 on the next. A match does not begin or end partway through a longer run of digits or letters.

Not detected: digits split across lines with no hyphen before the break, a break inside a digit group, digits outside ASCII (such as fullwidth digits), and more than one whitespace character between groups.

Required Parameters

This filter has no required parameters.

Optional Parameters

Parameter Description Default Value
canadaSinFilterStrategies A list of filter strategies. None
onlyValidPrefixes When true, do not report values beginning with 0 or 8. Neither is issued as a personal SIN, and 8 is used for business numbers. This rests on secondary sources rather than an official Government of Canada statement, so it is off by default. false
enabled When set to false, the filter will be disabled and not applied true
ignored A list of terms to be ignored by the filter. None

Filter Strategies

The filter may have zero or more filter strategies. When no filter strategy is given the default strategy of REDACT is used. When multiple filter strategies are given, they are evaluated in the order listed and only the first one whose condition is satisfied, or that has no condition, is applied. See Filter Strategies for details.

Strategy Description
REDACT Replace the sensitive text with a placeholder.
MASK Replace each character of the sensitive text with a mask character (* by default).
TRUNCATE Replace all but a few characters of the sensitive text with a truncation character (* by default).
RANDOM_REPLACE Replace the sensitive text with a similar, random value.
STATIC_REPLACE Replace the sensitive text with a given value.
CRYPTO_REPLACE Replace the sensitive text with its encrypted value.
HASH_SHA256_REPLACE Replace the sensitive text with its SHA256 hash value.
FPE_ENCRYPT_REPLACE Replace the sensitive text with a value generated by format-preserving encryption (FPE)
LAST_4 Replace the sensitive text with just the last four characters of the text.

Conditions

Each filter strategy may have one condition. See Conditions for details.

Conditional Description Operators
TOKEN Compares the value of the sensitive text. ==, !=, startswith
CONTEXT Compares the filtering context. == , !=
CONFIDENCE Compares the confidence in the sensitive text against a threshold value. < , <=, > , >=, ==, !=

Example Policy

{
   "identifiers": {
      "canadaSin": {
         "onlyValidPrefixes": true,
         "canadaSinFilterStrategies": [
            {
               "strategy": "REDACT",
               "redactionFormat": "{{{REDACTED-%t}}}"
            }
         ]
      }
   }
}