Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This tool allows you to use Google cloud function to rotate a regional SSL cert for a regional Google target https proxy.
Note: This tool only supports regional google ssl certs and regional google target https proxies.
You'll upload cert files to the configured GCS bucket, and it'll use the cert files to create a google ssl create and update the target https proxy. For clarity, here are the steps:
GOOGLE_PROJECT
env variable must be set for this script to work.gcloud
. This allows it to run on a Google Cloud Function.google-ssl deploy
command to deploy the function to Google Cloud functions. It creates the necessary resources, like an IAM service account with required permissions. While the Google Cloud Function itself does not require gcloud, some parts of the deploy command do rely on the gcloud
cli. Note: There was an attempt to use the pure Google Cloud SDK, but it proved unsatisfactory. The SDK does not document deployment well, and the interface was too complex at the time.Here's a suggested GCS bucket structure.
gcs://$BUCKET/certs/$DOMAIN/
Here's an example with files uploaded.
gcs://my-bucket/certs/example.com/proxies.txt
gcs://my-bucket/certs/example.com/cert-name-1.key
gcs://my-bucket/certs/example.com/cert-name-1.crt
Considerations:
gcloud compute ssl-certificates list
. Google ssl certificates need to be unique per Google project..key
and .crt
files and proxies.txt
must exist before the script will create the google ssl certificate and continue on. Otherwise the script exits early with a message in the logs..key
and .crt
files will trigger a target https proxy update.There needs to be a proxies.txt
file in the same GCS folder. The proxies.txt
lists target https proxies to be updated. This is because the only useful information passed to the cloud function in the received cloud_event
object is the bucket name and filename path. So a proxies.txt
contains a list of target proxie. If the proxies.txt
does not exist, the script logs a message.
This file should be a list of target https proxies separated by newlines. Here's a gcloud
command to help you grab a list to work with. You should remove most entries and only keep the proxies you want to update.
gcloud compute target-https-proxies list --format json | jq -r '.[].name'
For development, it is recommended to use Python virtualenv to set up the requirements. Here's a cheatsheet.
virtualenv -p python3 .venv
source .venv/bin/activate
Install the google-ssl tool.
pip install --editable .
This installs the google-ssl
command.
Note: The pip install --editable .
creates a shim that points to your local folder of the tool. This means any code edits you make are reflected without having to reinstall unless you move the folder. TLDR: You only have to install once.
Alternatively, if you have poetry installed. You can run
poetry install
See poetry site for detailed install docs: https://python-poetry.org/docs/#installation
CLI help:
google-ssl
google-ssl --help
google-ssl deploy --help
google-ssl rotate --help
You can also call the tool directly with python without installing the shim.
python google_ssl/cli.py
python google_ssl/cli.py --help
python google_ssl/cli.py deploy --help
python google_ssl/cli.py rotate --help
The shim makes the interface more user friendly, though and can be run from any location, not just the google-ssl project folder.
Deploy the code to google cloud functions.
google-ssl deploy --bucket my-bucket
This simply uses gcloud functions deploy to package up the code and deploy it to Google Cloud functions. The google function name is called google-ssl-rotator
by default. It can be set with the GS_FUNCTION_NAME
env var.
This can be useful before deploying code to Google Cloud Functions.
Copy a proxies.txt
file with a list of target https proxies you want to be updated and the SSL cert files you want to be used to create the Self-managed Google SSL Cert. Replace CERT_NAME
with your own value. The cert name needs to be unique across the entire Google project.
CERT_NAME=cert-name-1
gsutil cp proxies.txt gs://my-bucket/certs/example.com/proxies.txt
gsutil cp $CERT_NAME.key gs://my-bucket/certs/example.com/$CERT_NAME.key
gsutil cp $CERT_NAME.crt gs://my-bucket/certs/example.com/$CERT_NAME.crt
The files must exist on the GCS bucket before running the next command: rotate
.
The rotate
command "triggers" the ssl cert update logic and downloads the cert files from the GCS bucket. It performs the same logic that the google cloud function performs. You're just manually triggering it for rapid testing and development.
google-ssl rotate --bucket my-bucket --name certs/example.com/name.key
The nice thing about local testing is that you see the logs immediately in the same terminal.
You can also provide a --proxies
option to specify which target https proxies to update. In this case, the proxies.txt
is not downloaded and used. Example:
google-ssl rotate --bucket my-bucket --name certs/example.com/name.key --proxies demo-target-https-proxy-dev
You can build a test payload using the Google Cloud Function console Testing tab. Replace the name
and bucket
with some test values that exist in the GCS bucket.
{
"name": "certs/dev.example.com/test1.key",
"bucket": "certs-bucket-dev",
"contentType": "application/json",
"metageneration": "1",
"timeCreated": "2020-04-23T07:38:57.230Z",
"updated": "2020-04-23T07:38:57.230Z"
}
It will display a curl
command you can use in the Cloud Shell to test. It will return an "OK" http body response. Check the Logs tab to verify that it worked.
Last but not least, use gcloud to check that the google ssl cert was created and target https proxy was updated. Here's a cheatsheet with useful example commands:
gcloud compute ssl-certificates list
# useful to confirm certs are regional
gcloud compute ssl-certificates list --format json | jq '.[].selfLink'
gcloud compute ssl-certificates describe test1 --region us-central1
gcloud compute target-https-proxies describe demo-target-https-proxy-dev --region us-central1 | yq '.sslCertificates'
The tool also shows a hint/tip with similar check commands upon completion.
FAQs
Google Cloud Function SSL Cert Rotator tool
We found that google-ssl 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.