1.0.5 • Published 5 years ago

data-loss-signatures v1.0.5

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

data-loss-signatures

All Contributors

logo

Apache License FOSSA Status standard-readme compliant conventional commits JavaScript Style Guide

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

data-loss-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.

SecretDetected in
1.pem file extensionPotential cryptographic private keyextension
2Log fileLog files can contain secret HTTP endpoints, session IDs, API keys and other goodiesextension
3.pkcs12 file extensionPotential cryptographic key bundleextension
4.p12 file extensionPotential cryptographic key bundleextension
5.pfx file extensionPotential cryptographic key bundleextension
6.asc file extensionPotential cryptographic key bundleextension
7Pidgin OTR private keyfilename
8OpenVPN client configuration fileextension
9Azure service configuration schema fileextension
10Remote Desktop connection fileextension
11Microsoft SQL database fileextension
12Microsoft SQL server compact database fileextension
13SQLite database fileextension
14Microsoft BitLocker recovery key fileextension
15Microsoft BitLocker Trusted Platform Module password fileextension
16Windows BitLocker full volume encrypted data fileextension
17Java keystore fileextension
18Password Safe database fileextension
19Ruby 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
20Carrierwave configuration fileCan contain credentials for cloud storage systems such as Amazon S3 and Google Storagefilename
21Potential Ruby On Rails database configuration fileCan contain database credentialsfilename
22OmniAuth configuration fileThe OmniAuth configuration file can contain client application secretsfilename
23Django configuration fileCan contain database credentials, cloud storage system credentials, and other secretsfilename
241Password password manager database fileFeed it to Hashcat and see if you're luckyextension
25Apple Keychain database fileextension
26Network traffic capture fileextension
27GnuCash database fileextension
28Jenkins publish over SSH plugin filefilename
29Potential Jenkins credentials filefilename
30KDE Wallet Manager database fileextension
31Potential MediaWiki configuration filefilename
32Tunnelblick VPN configuration fileextension
33Sequel Pro MySQL database manager bookmark filefilename
34Little Snitch firewall configuration fileContains traffic rules for applicationsfilename
35Day One journal fileNow it's getting creepy...extension
36Potential jrnl journal fileNow it's getting creepy...filename
37Chef Knife configuration fileCan contain references to Chef serversfilename
38cPanel backup ProFTPd credentials fileContains usernames and password hashes for FTP accountsfilename
39Robomongo MongoDB manager configuration fileCan contain credentials for MongoDB databasesfilename
40FileZilla FTP configuration fileCan contain credentials for FTP serversfilename
41FileZilla FTP recent servers fileCan contain credentials for FTP serversfilename
42Ventrilo server configuration fileCan contain passwordsfilename
43Terraform variable config fileCan contain credentials for terraform providersfilename
44Shell configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
45Shell configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
46Shell configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
47Private SSH keyfilename
48Private SSH keyfilename
49Private SSH keyfilename
50Private SSH keyfilename
51SSH configuration filepath
52Potential cryptographic private keyextension
53Shell command history filefilename
54MySQL client command history filefilename
55PostgreSQL client command history filefilename
56PostgreSQL password filefilename
57Ruby IRB console history filefilename
58Pidgin chat client account configuration filepath
59Hexchat/XChat IRC client server list configuration filepath
60Irssi IRC client configuration filepath
61Recon-ng web reconnaissance framework API key databasepath
62DBeaver SQL database manager configuration filefilename
63Mutt e-mail client configuration filefilename
64S3cmd configuration filefilename
65AWS CLI credentials filepath
66SFTP connection configuration filefilename
67T command-line Twitter client configuration filefilename
68gitrob configuration filefilename
69Shell configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
70Shell profile configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
71Shell command alias configuration fileShell configuration files can contain passwords, API keys, hostnames and other goodiesfilename
72PHP configuration filefilename
73GNOME Keyring database fileextension
74KeePass password manager database fileFeed it to Hashcat and see if you're luckyextension
75SQL dump fileextension
76Apache htpasswd filefilename
77Configuration file for auto-login processCan contain username and passwordfilename
78Rubygems credentials fileCan contain API key for a rubygems.org accountpath
79Tugboat DigitalOcean management tool configurationfilename
80DigitalOcean doctl command-line client configuration fileContains DigitalOcean API key and other informationpath
81git-credential-store helper credentials filefilename
82GitHub Hub command-line client configuration fileCan contain GitHub API access tokenpath
83Git configuration filefilename
84Chef private keyCan be used to authenticate against Chef serverspath
85Potential Linux shadow fileContains hashed passwords for system userspath
86Potential Linux passwd fileContains system user informationpath
87Docker configuration fileCan contain credentials for public or private Docker registriesfilename
88NPM configuration fileCan contain credentials for NPM registriesfilename
89Environment configuration filefilename
90Contains word: credentialpath
91Contains word: passwordpath

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-loss-signatures --save-prod

3. Usage

Use data-loss-signatures.signatures to find file extensions, names, and paths that commonly leak secrets.

const { signatures } = require('data-loss-signatures')
// ⚠️ Note: the 'recursive-readdir' module is not bundled with
//    data-loss-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-loss-signatures module provides a Signatures class, which validates data-loss-signatures and converts regular expression strings to RE2 (whenever possible).

The data-loss-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-loss-signatures.Signature

A class that constructs Signature objects.

const { Signature, validParts, validTypes } = require('data-loss-signatures')

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

4.2. data-loss-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-loss-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/gregswindle/data-loss-signatures/raw/master/signatures.json'
package main

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

func main() {

	url := "https://gitlab.com/gregswindle/data-loss-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))

}
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", "gregswindle,data-loss-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/gregswindle/data-loss-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/gregswindle/data-loss-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:

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. 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.
  4. pattern: The string or regular expression to look for.

  5. 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 © 2019 Greg Swindle

FOSSA Status

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