https://github.com/crocs-muni/roca

ROCA: Infineon RSA key vulnerability

https://github.com/crocs-muni/roca

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: acm.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.1%) to scientific vocabulary

Keywords

detector discrete-logarithm fingerprinting infineon python roca roca-detec roca-detector rsa rsa-keys
Last synced: 5 months ago · JSON representation

Repository

ROCA: Infineon RSA key vulnerability

Basic Info
Statistics
  • Stars: 485
  • Watchers: 38
  • Forks: 93
  • Open Issues: 8
  • Releases: 1
Topics
detector discrete-logarithm fingerprinting infineon python roca roca-detec roca-detector rsa rsa-keys
Created over 8 years ago · Last pushed over 2 years ago
Metadata Files
Readme Contributing License

README.md

ROCA detection tool

Build Status

This tool is related to ACM CCS 2017 conference paper #124 Return of the Coppersmith’s Attack: Practical Factorization of Widely Used RSA Moduli.

It enables you to test public RSA keys for a presence of the described vulnerability.

Update 4.11.2017: Python 2.7, 3.4+ supported.

Update 30.10.2017: The paper of the attack is already online, ACM version.

Update 30.10.2017: The discrete logarithm detector is now implemented in the Python and used as a default. It detects the structure in the primes exploited by the factorizing algorithm.

Currently the tool supports the following key formats:

  • X509 Certificate, DER encoded, one per file, *.der, *.crt
  • X509 Certificate, PEM encoded, more per file, *.pem
  • X509 Certificate Signing Request, PEM encoded, more per file, *.pem
  • RSA PEM encoded private key, public key, more per file, *.pem (has to have correct header -----BEGIN RSA...)
  • SSH public key, *.pub, starting with "ssh-rsa", one per line
  • ASC encoded PGP key, *.pgp, *.asc. More per file, has to have correct header -----BEGIN PGP...
  • APK android application, *.apk
  • one modulus per line text file *.txt, modulus can be a) base64 encoded number, b) hex coded number, c) decimal coded number
  • JSON file with moduli, one record per line, record with modulus has key "mod" (int, base64, hex, dec encoding supported) certificate(s) with key "cert" / array of certificates with key "certs" are supported, base64 encoded DER.
  • LDIFF file - LDAP database dump. Any field ending with ;binary:: is attempted to decode as X509 certificate
  • Java Key Store file (JKS). Tries empty password & some common, specify more with --jks-pass-file
  • PKCS7 signature with user certificate

The detection tool is intentionally one-file implementation for easy integration / manipulation.

False positive

False positive detection rates:

  • Moduli detector: 2^-27
  • Discrete logarithm detector: 2^-154

Discrete logarithm detector is implemented only in the Python code, used as the default detection method.

Java and C# code ports are unmaintained since the original publication and we don't plan to upgrade these detectors to the more precise method. However PR are welcome!

Online checker

https://keychest.net/roca

The online checker is using the discrete logarithm detector algorithm.

Install with pip

Install the detector library + tool with pip (installs all dependencies):

pip install roca-detect

Local install

Execute in the root folder of the package:

pip install --upgrade --find-links=. .

Dependencies

It may be required to install additional dependencies so pip can install e.g. cryptography package.

CentOS / RHEL:

sudo yum install python-devel python-pip gcc gcc-c++ make automake autoreconf libtool openssl-devel libffi-devel dialog

Ubuntu: sudo apt-get install python-pip python-dev build-essential libssl-dev libffi-dev swig

Usage

To print the basic usage:

```

If installed with pip / manually

roca-detect --help

Without installation (can miss dependencies)

python roca/detect.py ```

The testing tool accepts multiple file names / directories as the input argument. It returns the report showing how many files has been fingerprinted (and which are those).

Example (no vulnerabilities found):

Running recursively on all my SSH keys and known_hosts:

$> roca-detect ~/.ssh 2017-10-16 13:39:21 [51272] INFO ### SUMMARY #################### 2017-10-16 13:39:21 [51272] INFO Records tested: 92 2017-10-16 13:39:21 [51272] INFO .. PEM certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. DER certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. RSA key files: . 16 2017-10-16 13:39:21 [51272] INFO .. PGP master keys: 0 2017-10-16 13:39:21 [51272] INFO .. PGP total keys: 0 2017-10-16 13:39:21 [51272] INFO .. SSH keys: . . . 76 2017-10-16 13:39:21 [51272] INFO .. APK keys: . . . 0 2017-10-16 13:39:21 [51272] INFO .. JSON keys: . . . 0 2017-10-16 13:39:21 [51272] INFO .. LDIFF certs: . . 0 2017-10-16 13:39:21 [51272] INFO .. JKS certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. PKCS7: . . . . . 0 2017-10-16 13:39:21 [51272] INFO No fingerprinted keys found (OK) 2017-10-16 13:39:21 [51272] INFO ################################

Example (vulnerabilities found):

Running recursively on all my SSH keys and known_hosts:

$> roca-detect ~/.ssh <b>2017-10-16 13:39:21 [51272] WARNING Fingerprint found in the Certificate</b> ... 2017-10-16 13:39:21 [51272] INFO ### SUMMARY #################### 2017-10-16 13:39:21 [51272] INFO Records tested: 92 2017-10-16 13:39:21 [51272] INFO .. PEM certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. DER certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. RSA key files: . 16 2017-10-16 13:39:21 [51272] INFO .. PGP master keys: 0 2017-10-16 13:39:21 [51272] INFO .. PGP total keys: 0 2017-10-16 13:39:21 [51272] INFO .. SSH keys: . . . 76 2017-10-16 13:39:21 [51272] INFO .. APK keys: . . . 0 2017-10-16 13:39:21 [51272] INFO .. JSON keys: . . . 0 2017-10-16 13:39:21 [51272] INFO .. LDIFF certs: . . 0 2017-10-16 13:39:21 [51272] INFO .. JKS certs: . . . 0 2017-10-16 13:39:21 [51272] INFO .. PKCS7: . . . . . 0 2017-10-16 13:39:21 [51272] INFO Fingerprinted keys found: 1 2017-10-16 13:39:21 [51272] INFO WARNING: Potential vulnerability 2017-10-16 13:39:21 [51272] INFO ################################

PGP key

In order to test your PGP key you can export it from your email client or download it from the PGP key server such as https://pgp.mit.edu/

You can also use gpg command line utility to export your public key:

bash gpg --armor --export your@email.com > mykey.asc

Advanced use case

Detection tool extracts information about the key which can be displayed:

roca-detect.py --dump --flatten --indent ~/.ssh/

TLS/SSL detection

The roca-detect-tls detects certificates from remote TLS/SSL ports. Provide a file with a newline-delimited list of address:port entries and use that file as input.

Example file: tls_list.txt github.com:443 google.com:443 internal.example.com:8080

Then run:

roca-detect-tls tls_list.txt

Fake moduli

It is possible to generate moduli that passes the moduli fingerprinting test but actually do not contain structure the factorization algorithm is using. Dlog moduli test do not mark those as positive.

Advanced installation methods

Virtual environment

It is usually recommended to create a new python virtual environment for the project:

virtualenv ~/pyenv source ~/pyenv/bin/activate pip install --upgrade pip pip install --upgrade --find-links=. .

Separate Python 2.7.13

We tested tool with Python 2.7.13 and it works (see Travis for more info). We have reports saying lower versions (<=2.6) do not work properly so we highly recommend using up to date Python 2.7

Use pyenv to install a new Python version locally if you cannot / don't want to update system Python.

It internally downloads Python sources and installs it to ~/.pyenv.

git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc exec $SHELL pyenv install 2.7.13 pyenv local 2.7.13

Python 3

Detection tools works also with Python 3.4+

Docker container

Run via Docker container to avoid environment inconsistency. Dockerfile source can be audited at https://hub.docker.com/r/unnawut/roca-detect/.

docker run --rm -v /path/to/your/keys:/keys --network none unnawut/roca-detect

Make sure to use --rm and --network none flags to disable container's network connection and delete the container after running.

Licensing

Code is licensed under permissive MIT license.

As there were requests on dual licensing under Apache 2.0 license (due to some doubts on compatibility) we are licensing the code also under Apache 2.0 license.

Pick license that suits you better, either MIT or Apache 2.0.

Language ports

This section contains links to different GIT repositories with language ports

Owner

  • Name: CRoCS
  • Login: crocs-muni
  • Kind: organization
  • Location: Faculty of Informatics, Masaryk University, Brno

Centre for Research on Cryptography and Security

GitHub Events

Total
  • Watch event: 3
  • Fork event: 2
Last Year
  • Watch event: 3
  • Fork event: 2

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 167
  • Total Committers: 14
  • Avg Commits per committer: 11.929
  • Development Distribution Score (DDS): 0.132
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Dusan Klinec d****c@g****m 145
Petr Svenda p****r@s****m 4
Joon Guillen j****n@m****m 3
Ludovit Scholtz l****2@g****m 2
Unnawut Leepaisalsuwanna 9****t 2
Hans-Joerg Hoexer h****r@g****e 2
Jaroslav Imrich j****h@j****k 2
Jonathan Rudenberg j****n@t****m 1
Nicolas Cavallari n****i@g****r 1
François Charlier f****r@r****m 1
Paul Kehrer p****r@g****m 1
Matus Nemec x****1@f****z 1
Jon Hart j****t@r****m 1
Kalinych 3****h 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 29
  • Total pull requests: 24
  • Average time to close issues: 5 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 26
  • Total pull request authors: 18
  • Average comments per issue: 2.69
  • Average comments per pull request: 0.79
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • scholtz (2)
  • hannob (2)
  • nealmcb (2)
  • jariq (1)
  • allRiceOnMe (1)
  • tiker (1)
  • steffen-heil (1)
  • mimaen (1)
  • alex (1)
  • frenzymadness (1)
  • acepace (1)
  • ptman (1)
  • jan-swiecki (1)
  • Kesner13 (1)
  • Marcool04 (1)
Pull Request Authors
  • hoexer (3)
  • scholtz (2)
  • unnawut (2)
  • jariq (2)
  • pirxthepilot (2)
  • steffen-heil (1)
  • Kalinych (1)
  • titanous (1)
  • reaperhulk (1)
  • jhart-r7 (1)
  • fcharlier (1)
  • gilb3rt (1)
  • Hamid-K (1)
  • smuda (1)
  • frenzymadness (1)
Top Labels
Issue Labels
enhancement (2)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 192 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 3
    (may contain duplicates)
  • Total versions: 42
  • Total maintainers: 1
proxy.golang.org: github.com/crocs-muni/roca
  • Versions: 18
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 7.0%
Last synced: 6 months ago
pypi.org: roca-detect

ROCA key detector / fingerprinter tool

  • Versions: 24
  • Dependent Packages: 0
  • Dependent Repositories: 3
  • Downloads: 192 Last month
Rankings
Stargazers count: 2.9%
Forks count: 4.6%
Average: 8.8%
Dependent repos count: 9.0%
Dependent packages count: 10.0%
Downloads: 17.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

csharp/RocaTest/packages.config nuget
  • Portable.BouncyCastle 1.8.1.3
setup.py pypi
  • coloredlogs *
  • cryptography >=1.2.3
  • future *
  • pgpdump *
  • python-dateutil *
  • setuptools >=1.0
  • six *
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v2 composite
  • github/codeql-action/analyze v1 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v1 composite
csharp/RocaTest/RocaTest.csproj nuget