1.2.4 • Published 4 years ago

@data-leakage-protection/signatures v1.2.4

Weekly downloads
1
License
Apache-2.0
Repository
gitlab
Last release
4 years ago

signatures (@data-leakage-protection/signatures)

logo

Product summary Identify confidential and sensitive info in source code repositories by data-loss "signatures".

@data-leakage-protection/signatures is a Node.js module offsite web page for storing and accessing to data-leakage detection definitions. We call the data structure that represents a data-leakage detection defintion a "signature." We store a community-tested list of signatures in a file called signatures.json.

Table of Contents

1. Security

citation Data leakage is the unauthorized transmission of data from within an organization to an external destination or recipient.^1

One of the most common forms of data-loss (aka, "data leakage") happens when developers (inadvertently) commit and push passwords, access-tokens, and sensitive data to a source-control management system (like Git). Consequently, confidential information "leaks" into search results and commit history.

The signatures.json contains a growing list of definitions to help you detect secrets in your source code repositories.

SignatureDetected in
1.asc file extensionPotential cryptographic key bundleextension
2.p12 file extensionPKCS#12 (.p12): potential cryptographic key bundleextension
3.pem file extensionPotential cryptographic private keyextension
4.pfx file extensionPKCS#12 (.pfx): Potential cryptographic key bundleextension
5.pkcs12 file extensionPKCS#12 (.pkcs12): Potential cryptographic key bundleextension
61Password password manager database fileFeed it to Hashcat and see if you're luckyextension
7AWS API Key__contents
8AWS CLI credentials file__path
9Apache htpasswd file__filename
10Apple Keychain database file__extension
11Azure service configuration schema file__extension
12Carrierwave configuration fileCan contain credentials for cloud storage systems such as Amazon S3 and Google Storagefilename
13Chef Knife configuration fileCan contain references to Chef serversfilename
14Chef private keyCan be used to authenticate against Chef serverspath
15Configuration file for auto-login processCan contain username and passwordfilename
16Contains word: credential__path
17Contains word: password__path
18DBeaver SQL database manager configuration file__filename
19Day One journal fileNow it's getting creepy...extension
20DigitalOcean doctl command-line client configuration fileContains DigitalOcean API key and other informationpath
21Django configuration fileCan contain database credentials, cloud storage system credentials, and other secretsfilename
22Docker configuration fileCan contain credentials for public or private Docker registriesfilename
23Environment configuration file__filename
24Facebook Oauth__contents
25FileZilla FTP configuration fileCan contain credentials for FTP serversfilename
26FileZilla FTP recent servers fileCan contain credentials for FTP serversfilename
27GNOME Keyring database file__extension
28Generic API Key__contents
29Generic Secret__contents
30Git configuration file__filename
31GitHub__contents
32GitHub Hub command-line client configuration fileCan contain GitHub API access tokenpath
33GnuCash database file__extension
34Google (GCP) Service-account__contents
35Google Oauth__contents
36Heroku API Key__contents
37Hexchat/XChat IRC client server list configuration file__path
38Irssi IRC client configuration file__path
39Java keystore file__extension
40Jenkins publish over SSH plugin file__filename
41KDE Wallet Manager database file__extension
42KeePass password manager database fileFeed it to Hashcat and see if you're luckyextension
43Little Snitch firewall configuration fileContains traffic rules for applicationsfilename
44Log fileLog files can contain secret HTTP endpoints, session IDs, API keys and other goodiesextension
45Microsoft BitLocker Trusted Platform Module password file__extension
46Microsoft BitLocker recovery key file__extension
47Microsoft SQL database file__extension
48Microsoft SQL server compact database file__extension
49Mutt e-mail client configuration file__filename
50MySQL client command history file__filename
51NPM configuration fileCan contain credentials for NPM registriesfilename
52Network traffic capture file__extension
53OmniAuth configuration fileThe OmniAuth configuration file can contain client application secretsfilename
54OpenVPN client configuration file__extension
55PGP private key block__contents
56PHP configuration file__filename
57Password Safe database file__extension
58Password in URL__contents
59Pidgin OTR private key__filename
60Pidgin chat client account configuration file__path
61PostgreSQL client command history file__filename
62PostgreSQL password file__filename
63Potential Jenkins credentials file__filename
64Potential Linux passwd fileContains system user informationpath
65Potential Linux shadow fileContains hashed passwords for system userspath
66Potential MediaWiki configuration file__filename
67Potential Ruby On Rails database configuration fileCan contain database credentialsfilename
68Potential cryptographic private key__extension
69Potential jrnl journal fileNow it's getting creepy...filename
70Private SSH key_rsafilename
71Private SSH key_dsafilename
72Private SSH key_ed25519filename
73Private SSH key_ecdsafilename
74RSA private key__contents
75Recon-ng web reconnaissance framework API key database__path
76Remote Desktop connection file__extension
77Robomongo MongoDB manager configuration fileCan contain credentials for MongoDB databasesfilename
78Ruby IRB console history file__filename
79Ruby On Rails secret token configuration fileIf the Rails secret token is known, it can allow for remote code execution (http://www.exploit-db.com/exploits/27527/)filename
80Rubygems credentials fileCan contain API key for a rubygems.org accountpath
81S3cmd configuration file__filename
82SFTP connection configuration file__filename
83SQL dump file__extension
84SQLite database file__extension
85SSH (DSA) private key__contents
86SSH (EC) private key__contents
87SSH (OPENSSH) private key__contents
88SSH configuration file__path
89Sequel Pro MySQL database manager bookmark file__filename
90Shell command alias configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
91Shell command history file__filename
92Shell configuration file(.exports): Shell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
93Shell configuration file(.functions): Shell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
94Shell configuration file(.extra): Shell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
95Shell configuration file(bash, zsh, csh): Shell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
96Shell profile configuration file(profile): Shell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
97Slack Token__contents
98Slack Webhook__contents
99T command-line Twitter client configuration file__filename
100Terraform variable config fileCan contain credentials for terraform providersfilename
101Tugboat DigitalOcean management tool configuration__filename
102Tunnelblick VPN configuration file__extension
103Twilio API Key__contents
104Twitter Oauth__contents
105Ventrilo server configuration fileCan contain passwordsfilename
106Windows BitLocker full volume encrypted data file__extension
107cPanel backup ProFTPd credentials fileContains usernames and password hashes for FTP accountsfilename
108git-credential-store helper credentials file__filename
109gitrob configuration file__filename

2. Install

Before you begin, you'll need to have these

Terminal Open a Terminal and enter the following command:

# As a dependency in your Node.js app
npm i @data-leakage-protection/signatures --save-prod

3. Usage

Use @data-leakage-protection/signatures.signatures to find file extensions, names, and paths that commonly leak secrets.

const { signatures } = require('@data-leakage-protection/signatures')
// ⚠️ Note: the 'recursive-readdir' module is not bundled with
//    @data-leakage-protection/signatures. 'recursive-readdir' is referenced
//    only as an example.
const recursiveReaddir = require('recursive-readdir')

const potentialLeaks = recursiveReaddir('/path/to/local/repo')
  .then(files => files
    .map(file => signatures
    .map(signature => signature.match(file)))
  )
  .catch(err => err)

4. API

The @data-leakage-protection/signatures module provides a Signatures class, which validates @data-leakage-protection/signatures and converts regular expression strings to RE2 (whenever possible).

The @data-leakage-protection/signatures module's public API provides:

  1. factory method: a convenience function that creates a signature object.
  2. nullSignature: implements a default object literal with all signatures properties set to null.
  3. Signature: a class that constructs a signature object.
  4. signatures: an array of Signature instances.
  5. toArray(data: {String|Array.<Object>}): generates an Array.<Signature> from a JSON string or object literal array.
  6. validParts: a constants enum of valid Signature.prototype.part values.
  7. validTypes: a constants enum of valid Signature.prototype.type values.

4.1. @data-leakage-protection/signatures.Signature

A class that constructs Signature objects.

const { Signature, validParts, validTypes } = require('@data-leakage-protection/signatures')

const signature = new Signature({
  caption: 'Potential cryptographic private key',
  description: '',
  part: validParts.EXTENSION,
  pattern: '.pem',
  type: validTypes.MATCH
})

4.2. @data-leakage-protection/signatures.Signature.prototype.match

Discover possible data leaks by matching a Signature pattern against file extensions, names, and paths.

const rsaTokenSignature = new Signature({
  'caption': 'Private SSH key',
  'description': '',
  'part': 'filename',
  'pattern': '^.*_rsa$',
  'type': 'regex'
})

const suspiciousFilePath = '/hmm/what/might/this/be/id_rsa'
rsaTokenSignature.match(suspiciousFilePath)
// => ['/hmm/what/might/this/be/id_rsa']

const fileThatIsJustBeingCoolBruh = 'file/that/is/just/being/cool/bruh'
rsaTokenSignature.match(suspiciousFilePath)
// => null

source code Review the source code for signature.

5. Accessing signatures with other tools and programming languages

You can access signatures.json without the @data-leakage-protection/signatures Node module. Select a tool or programming language below to view examples.

You can access data-loss rules using HTTPS. You can GET all signatures directly from Gitlab with cURL.

curl -X GET \
  'https://gitlab.com/data-leakage-protection/signatures/raw/master/signatures.json'

package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://gitlab.com/data-leakage-protection/signatures/raw/master/signatures.json"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Private-Token", "<your-personal-token>")
	req.Header.Add("cache-control", "no-cache")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

OkHttpClient client = new OkHttpClient();

String signaturesJson = "https://gitlab.com/data-leakage-protection/signatures/raw/master/signatures.json";

Request request = new Request.Builder()
  .url(signaturesJson)
  .get()
  .addHeader("Accept", "*/*")
  .addHeader("Cache-Control", "no-cache")
  .addHeader("Host", "gitlab.com")
  .addHeader("accept-encoding", "gzip, deflate")
  .addHeader("Connection", "keep-alive")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

const http = require('https')

const options = {
  method: 'GET',
  hostname: ['gitlab', 'com'],
  path: ['api', 'v4', 'projects'],
  headers: {
    'Private-Token': '<your-access-token>',
    'cache-control': 'no-cache'
  }
}

const req = http.request(options, res => {
  const chunks = []

  res.on('data', chunk => {
    chunks.push(chunk)
  })

  res.on('end', () => {
    var body = Buffer.concat(chunks)
    console.log(body.toString())
  })
})

req.end()

Python3

import http.client

conn = http.client.HTTPConnection("gitlab,com")

payload = ""

headers = {
  'Accept': "application/json",
  'cache-control': "no-cache"
}

conn.request("GET", "data-leakage-protection/signatures,raw,master,signatures.json", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Python2

import requests

url = "https://gitlab.com/data-leakage-protection/signatures/raw/master/signatures.json"

payload = ""
headers = {
  'Accept': "application/json",
  'cache-control': "no-cache"
}

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)

require 'uri'
require 'net/http'

url = URI("'https://gitlab.com/data-leakage-protection/signatures/raw/master/signatures.json")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["Private-Token"] = '<your-personal-token>'
request["cache-control"] = 'no-cache'

response = http.request(request)
puts response.read_body

6. Maintainers

@gregswindle

Information for Maintainers The Maintainer Guide has useful information for Maintainers and Trusted Committers.

7. Contributions

We gratefully accept Merge Requests! Here's what you need to know to get started.

Before submitting a Merge Request, please read Before submitting a Merge Request, please read our:

All Contributors FOSSA Status standard-readme compliant conventional commits JavaScript Style Guide

Thanks goes to our awesome contributors (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

7.1. Adding a Signature

Before adding a new Signature, please review all current definitions: the Signature might already exist.

If the Signature does not exist, please be sure to add your Signature with the following properties:

  1. caption: A succinct summary for the Signature. Think of caption as a well-written email subject.

  2. description: Provide more details about the Signature if necessary. description is especially useful for differentiating similar Signatures.

  3. hash: A hexidecimal SHA256 representation of a Signature (with ordered properties).

  4. name: The Signature's caption, converted to kebab-case.

  5. part: An enumeration that defines what the Signature is evaluating. Valid values are:

    • contents: The string(s) within a file.
    • extension: A file extension (which defines the Content-Type or mime-type).
    • filename: The unique name of the file.
    • path: The directory path relative to the repo and without the filename.
  6. pattern: The string or regular expression to look for.

  7. type: An enumeration that defines how to evaluate for secrets. Valid values are:

    • match: A strict string equivalency evaluation.
    • regex: A regular expression "search" or "test".

7.2. Editing a Signature

Edits are welcome! Just be sure to unit test.

7.3. Removing a Signature

Please provide a testable justification for any Signature removal.

8. License

Apache 2.0 License © 2019 Greg Swindle.

FOSSA Status

View detailed legal NOTICEs View all FOSS legal notices.

9. References and Attributions

^1: What is Data Leakage? Defined, Explained, and Explored | Forcepoint. (2019) Retrieved January 27, 2019, from https://www.forcepoint.com/cyber-edu/data-leakage