Getting Data In

Masking SSN info into splunk at index time

mike7860
Explorer

I would like to know how to mask SSN information in splunk at index time. There is a documentation available on the splunk homepage. But the question arises that whether configurations of props.conf and transforms.conf be done at the indexer side as we have a multi-tiered splunk network? Then, the other question is how do I compile a rex expression for masking SSN data from the followin log source:

index=web sourcetype=weblogic_app ssn





/env:Header
env:Body

ns2:ContractsWithProductInfoResponse
ns2:ParticipantDetails
*ns2:Pin2895237/ns2:Pin
ns2:SSN/ns2:SSN
*

Tags (1)

yannK
Splunk Employee
Splunk Employee

try the sedcmd command in the props.conf, and deploy on your parsing instances :
see http://docs.splunk.com/Documentation/Splunk/6.1.4/Data/Anonymizedatausingconfigurationfiles

  • on all indexers
  • on all heavy forwarders
  • in case of csv/iis or INDEXED_EXTRACTION sourcetypes (since splunk 6.1), on the forwarders (even the Universal and Lightweight)

    [mysourcetype]
    SEDCMD-hidessn=s/(GovernmentIDNumber: SSN: \d{3})(\d{6})/\1xxxxxxx/g

GovernmentIDNumber: SSN: 555666666
-> GovernmentIDNumber: SSN: 555xxxxxxx

johnhsu
Observer

Regex for masking Social Security Number in XML TAG

Result:

<relatedPolicies />
<socialSecurityNumber>###-##-1234</socialSecurityNumber>
<ssnRefusedIndicator>false</ssnRefusedIndicator>

transforms.conf:

[SSN-anonymizer]
REGEX = (?ms)^(.*)\<[sS]ocialSecurityNumber>\d{3}-?\d{2}-?(\d{4}.*)$
FORMAT = $1<socialSecurityNumber>###-##-$2
DEST_KEY = _raw

Note:
In Splunk V6.0.1
In my testing, masking function failed if the record is very large, for example 15KB, and SSB is out of 100 lines (or some position) .

Thanks
Sincerely
John Hsu

0 Karma

johnhsu
Observer

Sorry! Try again

should be

REGEX = (?ms)^(.\*)\<[sS]ocialSecurityNumber>\d{3}-?\d{2}-?(\d{4}.\*)$

Thanks
Sincerely
John Hsu

0 Karma

Lowell
Super Champion

Johnsu, just so you know. You can edit your own answers. That's preferred over posting new ones. Thanks for taking the time to post your corrections!

johnhsu
Observer

Corrected: Don't know why missed the star "" after those two dot in post
Try post again:
"REGEX = (?ms)^(.
)<[sS]ocialSecurityNumber>\d{3}-?\d{2}-?(\d{4}.*)$"

Thanks
Sincerely
John Hsu

0 Karma

rgcurry
Contributor

Check out the Splunk Doc page at

http://docs.splunk.com/Documentation/Splunk/4.2.1/Data/Anonymizedatausingconfigurationfiles

It includes a SED example that fits closely to what you are wanting to do. The only difference is your data is XML formatted versus the 'straight' text of the doc example but that is not big deal to deal with in the RegEx you'd use to pinpoint your data to mask.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...