All Projects → masonicboom → Ipscrub

masonicboom / Ipscrub

IP address anonymizer module for nginx

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Ipscrub

Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: ✭ 14,096 (+6549.06%)
Mutual labels:  gdpr, nginx
Net Shield
An Easy and Simple Anti-DDoS solution for VPS,Dedicated Servers and IoT devices - Beta
Stars: ✭ 202 (-4.72%)
Mutual labels:  nginx
Laravel Gdpr
GDPR compliance with ease.
Stars: ✭ 189 (-10.85%)
Mutual labels:  gdpr
Gdprdialog
GDPR fragment dialog implementation
Stars: ✭ 197 (-7.08%)
Mutual labels:  gdpr
Off By Slash
Burp extension to detect alias traversal via NGINX misconfiguration at scale.
Stars: ✭ 192 (-9.43%)
Mutual labels:  nginx
Blog
MyBlog
Stars: ✭ 197 (-7.08%)
Mutual labels:  nginx
Blss
NGINX-based Live Media Streaming Server
Stars: ✭ 187 (-11.79%)
Mutual labels:  nginx
Nginx Module Vts
Nginx virtual host traffic status module
Stars: ✭ 2,518 (+1087.74%)
Mutual labels:  nginx
Cleargdpr
GDPR Compliance Solution
Stars: ✭ 201 (-5.19%)
Mutual labels:  gdpr
Nginx Sso
SSO authentication provider for the auth_request nginx module
Stars: ✭ 195 (-8.02%)
Mutual labels:  nginx
Exporter exporter
A reverse proxy designed for Prometheus exporters
Stars: ✭ 194 (-8.49%)
Mutual labels:  nginx
Nginx Http Echo Module
A simple Nginx echo module
Stars: ✭ 192 (-9.43%)
Mutual labels:  nginx
Bitnami Docker Nginx
Bitnami nginx Docker Image
Stars: ✭ 198 (-6.6%)
Mutual labels:  nginx
Laravel Deployment
📗[WIP] 追求质量的 Laravel 应用部署上线课程。
Stars: ✭ 190 (-10.38%)
Mutual labels:  nginx
Paste
Paste is a project that started from the files pastebin.com used before it was bought.
Stars: ✭ 204 (-3.77%)
Mutual labels:  nginx
External Auth Server
easy auth for reverse proxies
Stars: ✭ 189 (-10.85%)
Mutual labels:  nginx
Feathers Vue
A boiler plate template using Feathers with Email Verification, Vue 2 with Server Side Rendering, stylus, scss, jade, babel, webpack, ES 6-8, login form, user authorization, and SEO
Stars: ✭ 195 (-8.02%)
Mutual labels:  nginx
Nginx Link Function
It is a NGINX module that provides dynamic linking to your application in server context and call the function of your application in location directive
Stars: ✭ 197 (-7.08%)
Mutual labels:  nginx
Blog
Hi, I am CrazyCodes, and here are all my articles
Stars: ✭ 212 (+0%)
Mutual labels:  nginx
Oil
Stars: ✭ 209 (-1.42%)
Mutual labels:  gdpr

ipscrub

ipscrub is an IP address anonymizer for nginx log files. It's an nginx module that generates an IP-based hash. You can use this hash to link requests from the same source, without identifying your users by IP address.

Screenshot of nginx logs when using ipscrub

TOC

Security Model

  1. On initialization, and again every PERIOD, generate salt using 128bits from arc4random_buf().
  2. On each request, generate masked IP address as HASH(salt ++ IP address).
  3. Log masked IP address.

ipscrub uses arc4random to generate random nonces (see Theo de Raat's talk on arc4random for a great overview). On Linux this requires installing libbsd (package libbsd-dev on Ubuntu/Debian).

ALSO NOTE: the generated hash WILL change on each PERIOD transition, so you will only have continuity within each PERIOD. But because users can transition between networks at any time (e.g. wifi -> cellular), you'd have this type of issue even if you were storing raw IPs.

Threat Model

  1. Government presents you with an IP address and demands identification of user corresponding to that address.
  2. Government identifies a user e.g. by email address, and demands IP address they had at some point in time.

In threat scenario (1), the goal is to compute the masked IP corresponding to a target IP address. This will only be possible if the demand is made before the end of the current PERIOD.

Scenario (2) is defended against because the server operator does not know the salt, and cannot infer it based on the request timestamp, because the salt is generated from a nonce that is only stored in memory. The server operator would have to be an accomplice in this case, but that is more simply accomplished by the server operator just recording the unmasked IP. So this security/threat model does not defend against a malicious server operator, but that is not the point. It does defend against an honest server operator being compelled in threat scenarios (1) and (2).

Usage

Installation

Building From Source

ipscrub can be built statically with nginx or as a dynamic module. See the Makefile for examples of both ways.

Packages

Configuration

In your nginx.conf,

  1. At the top-level, load the module by adding the line load_module ngx_ipscrub_module.so; (NOTE: only if you built as a dynamic module).
  2. Set ipscrub_period_seconds <NUM SECONDS PER PERIOD>; (optional).
  3. In your log_format directives, replace $remote_addr with $remote_addr_ipscrub.
  4. Reload your nginx config.

NOTE: nginx may still leak IP addresses in the error log. If this is a concern, disable error logging or wipe the log regularly.

Running Tests

make test

Checking for Updates

make check-up-to-date

This will have a non-zero exit code if you aren't up-to-date, so you can automate regular checks.

Changelog

  • 1.0.1 fixed vulnerability to unmasking hashed IPs (thanks to @marcan)
  • 1.0.0 initial release

GDPR

GDPR goes into effect on May 25, 2018. It legislates the handling of personal data about your users, including IP addresses.

From https://www.eugdpr.org/gdpr-faqs.html:

What constitutes personal data?

Any information related to a natural person or ‘Data Subject’, that can be used to directly or indirectly identify the person. It can be anything from a name, a photo, [...], or a computer IP address.

The hashes generated by ipscrub let you correlate nginx log entries by IP address, without actually storing IP addresses, reducing your GDPR surface area.

YAGNI

Why are you logging IP addresses anyway? You Ain't Gonna Need It. If you want geolocation, just use MaxMind's GeoIP module in conjunction with ipscrub.

License

Copyright 2018 Mason Simon

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. If you use this module in a production service that has an associated privacy policy, that privacy policy must include this text "This service uses ipscrub (http://www.ipscrub.org)." or similar text in the same spirit, which includes that link to http://www.ipscrub.org.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Alternative Licensing

If you would like to use ipscrub without attribution in your privacy policy, or to discuss custom development, get in touch and we can work something out (email address is in my GitHub profile, @masonicb00m on Twitter).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].