
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Twyn is a security tool that compares the name of your dependencies against a set of the most popular ones, in order to determine if there is any similarity between them, preventing you from using a potentially illegitimate one. In short, Twyn protects you against typosquatting attacks.
It works as follows:
--dependency-file
) or some dependencies introduced through the CLI (--dependency
). If no option was provided, it will try to find a dependencies file in your working path.Twyn is available on PyPi repository, you can install it by running
pip install twyn
Twyn provides a Docker image, which can be found here.
Use it like so:
docker pull elementsinteractive/twyn:latest
docker run elementsinteractive/twyn --help
To run twyn simply type:
twyn run <OPTIONS>
For a list of all the available options as well as their expected arguments run:
twyn run --help
It can happen that a legitimate package known by the user raises an error because is too similar to one of the most trusted ones.
You can then add this packages to the allowlist
, so it will be skipped:
twyn allowlist add <package>
To remove it simply:
twyn allowlist remove <package>
To specify a dependency file through the command line run:
twyn run --dependency-file <file path>
Currently it supports these dependency file formats:
requirements.txt
poetry.lock
You can also check a dependency by entering it through the command line:
twyn run --dependency <dependency>
It does accept multiple dependencies at a time:
twyn run --dependency <dependency> --dependency <another_dependency>
When this option is selected, no dependency file is checked.
You can choose between different operational modes. These will determine which dependencies from the trusted set the analyzed dependency can be a typosquat of.
all
: Default option. It is the most exhaustive mode. It will check your package names against all the trusted ones without any assumption.nearby-letter
: It will assume a typo on the first letter of the dependency is possible, but improbable if letters are farther apart in the keyboard. Specifically, it will compare the analyzed dependency against dependencies whose first letter is one step away in an ANSI
keyboard layout.first-letter
: It will assume a typo on the first letter is very improbable, and won't compare the analyzed dependency against dependencies with a different first letter.[!NOTE] Selecting an option is a matter of preference:
all
is the slowest, but will have more false positives and less false negatives; whilefirst-letter
is the fastest, but it will have less false positives and more false negatives.
To select a specific operational mode through the CLI use the following command
twyn run --selector-method <method>
You can save your configurations in a .toml
file, so you don't need to specify them everytime you run Twyn in your terminal.
By default, it will try to find a pyproject.toml
file in your working directory when it's trying to load your configurations.
However, you can specify a config file as follows:
twyn run --config <file>
All the configurations available through the command line are also supported in the config file.
[tool.twyn]
dependency_file="/my/path/requirements.txt"
selector_method="first_letter"
logging_level="debug"
allowlist=["my_package"]
pypi_reference="https://mirror-with-trusted-dependencies.com/file.json"
[!WARNING]
twyn
will have a default reference URL for every source of trusted packages that is configurable. If you want to protect yourself against spoofing attacks, it is recommended to set your own reference url.
The file format for each reference is as follows:
{
rows: {project: string}[]
}
FAQs
Unknown package
We found that twyn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.