Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@cag-group/utils
Advanced tools
Use in a server application to implement basic authentication in it's REST API.
The class BasicAuthChecker
is used in code the do authorization. Credentials are read from the local directory
secrets
which when running locally contains uncommitted credentials for development,
and in Kubernetes a ecret containing the credentials are mounted at secrets
so the application always reach it by:
const credentials = require('../secrets/api-credentials/api-credentials.json')
disregarding if running on a local laptop, in cloud stage or cloud prod.
Use in code like this:
const {BasicAuthChecker} = require('@cag-group/utils')
const credentials = require('../secrets/api-credentials/api-credentials.json')
...
const checker = new BasicAuthChecker(credentials)
const username = checker.getValidUser(req)
if (!username) {
console.log('Missing/invalid auth')
return res.sendStatus(401)
}
Create file api-credentials.json
in the folder secrets/api-credentials
with accounts for local tests:
[
{ "name": "u1", "pass": "somepass" },
{ "name": "u1", "pass": "changedpass" },
{ "name": "u2", "pass": "anotherpass" }
]
do not commit files in /secrets
, these are for local tests.
In the example above user "u1" is present twice with different passwords. basic-auth-checker supports this in order to support change of API-passwords without downtime.
Create a local file api-credentials.json
in the root directory with the intended users and generated passwords (see command below).
Create the secret:
kubectl -n your-namespace create secret generic api-credentials --from-file=api-credentials.json
containers:
: volumes:
- name: api-credentials
secret:
secretName: api-credentials
volumeMounts:
- name: api-credentials
mountPath: /server/secrets/api-credentials/
readOnly: true
api-credentials.json
from your secrets vault and save it in the root folder.dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2- | rev | tr -dc _A-Z-a-z-0-9 | head -c15;
kubectl -n your-namespace delete secret api-credentials
kubectl -n your-namespace create secret generic api-credentials --from-file=api-credentials.json
Restart the pod in order for it to read the changed secret:
kubectl -n your-namespace delete pod <podname>
FAQs
Various helpers, utilities and tools
The npm package @cag-group/utils receives a total of 0 weekly downloads. As such, @cag-group/utils popularity was classified as not popular.
We found that @cag-group/utils demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.