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.
A Python package to facilitate JSON Web Encryption (JWE) with enhanced security, leveraging AWS Key Management Service (KMS) and Secrets Manager for secure input and output handling.
jwe-encryptify
is a Python package designed for secure encryption and decryption using
JSON Web Encryption (JWE), enhanced by AWS Key Management Service (KMS) and AWS Secrets Manager
integration. This package offers a straightforward solution for handling sensitive data, allowing
encrypted data exchange while securely managing encryption keys through AWS.
You can install the package via pip
from PyPI:
pip install jwe-encryptify
AWS_DEFAULT_REGION
as an environment variable or configure it in
your AWS settings.Use the encrypt
method to secure JSON data with a public key stored in AWS Secrets Manager.
from jwe_crypto import encrypt
# Data to encrypt
data_to_encrypt = {"user": "John Doe", "account_id": "123456"}
# Encrypt the data
jwe_encrypted_token = encrypt(
kms_id="your-kms-key-id", # AWS KMS key ID for encryption
secret_name="your-secret-name", # AWS Secrets Manager secret name
secret_key="public-key", # Key name in the secret (public key)
api_response=data_to_encrypt # JSON data to encrypt
)
print("Encrypted JWE Token:", jwe_encrypted_token)
Use the encrypt
method to secure JSON data using an AWS KMS key.
from kms_crypto import encrypt
# Data to encrypt
data_to_encrypt = {"user": "John Doe", "account_id": "123456"}
# Encrypt the data using KMS
kms_encrypted_value = encrypt(
kms_id="your-kms-key-id", # AWS KMS key ID used for encryption
plaintext=str(data_to_encrypt) # Convert the JSON data to a string
)
print("Encrypted KMS Value:", kms_encrypted_value)
Use the decrypt
method to decrypt an encrypted JWE token using a private key from AWS Secrets
Manager.
from jwe_crypto import decrypt
# JWE token to decrypt
jwe_token = "your-encrypted-jwe-token"
# Decrypt the data
decrypted_data = decrypt(
kms_id="your-kms-key-id", # AWS KMS key ID
secret_name="your-secret-name", # AWS Secrets Manager secret name
secret_key="private-key", # Key name in the secret (private key)
jwe_payload=jwe_token # Encrypted JWE payload
)
print("Decrypted Data:", decrypted_data)
Use the decrypt
method to decrypt an encrypted value using an AWS KMS key and encryption context.
from kms_crypto import decrypt
# Encrypted value to decrypt
encrypted_value = "your-encrypted-kms-value"
# Decrypt the data using KMS
decrypted_data = decrypt(
kms_id="your-kms-key-id", # AWS KMS key ID used for decryption
lambda_function_name="your-lambda-function-name", # Encryption context
encrypted_value=encrypted_value # Encrypted value to decrypt
)
print("Decrypted Data:", decrypted_data)
Ensure the following permissions are assigned to your AWS IAM role or user:
kms:Encrypt
kms:Decrypt
secretsmanager:GetSecretValue
The package requires the following dependencies:
jwcrypto
: For JWE encoding and decoding.boto3
: AWS SDK for Python.botocore
: Core library used by boto3.
Install all dependencies automatically via pip install jwe-encryptify.This project is licensed under the MIT License.
Contributions are welcome! Submit issues or pull requests to enhance the package. For major changes, please open a discussion first.
M Santhosh Kumar Initial work santhoshse7en@gmail.com
FAQs
A Python package to facilitate JSON Web Encryption (JWE) with enhanced security, leveraging AWS Key Management Service (KMS) and Secrets Manager for secure input and output handling.
We found that jwe-encryptify 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
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.