![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
insecure-but-secure-enough
Advanced tools
Lightweight tools for signing and encrypting cookies, urls and stuff. This package isn't really secure, but it is secure enough for most needs.
This package is "insecure", but secure enough.
The idea behing being "secure_enough" is to allow for "autologin cookies" and "instant login" urls for social web applications.
This package is very similar to "ItsDangerous" - which is now popular, but was unknown when this package was first written.
Two important things to note:
This package supports the following schemes for encrypting data:
This package supports the following schemes for signing data:
The data transformation order is as follows :
Long ago, I had a class that would do a trivial encryption on cookie data, coupled with a lightweight hash to handle timeout events. This way you wouldn't always have to decrypt data to do a light verification.
The general flow was this:
To encode: cookie = encypted_data + timestamp + hash(encrypted_data + timestamp + secret)
To decode: (payload, timestamp, hash) = cookie if hash != hash (payload, timestamp, secret): raise InvalidHash() if timestamp > timeout: raise Timeout() data = decrypt(payload)
The encryption I used was a lightweight port from a CPAN (Perl) module, so it could be blown away in seconds today.
When i decided to re-implement this, looking around I found a handful of similar projects - which I've borrowed heavily from.
They include:
This largely re-implements all of those, along with some other functionality.
Right now, data is a base64_url_encoded
version of a string, concatenated list,
or json object (for dicts). I opted against using pickle
, because this format
makes it easier to work with other web technologies (js, php, etc).
This might move to an all json version one day.
Check demo.py
to see an overview of how this works.
signed_request_create
and signed_request_verify
are both handled as @classmethods
- along with their support functions.
That means you can call them directly without an object instance.
I built them as @classmethods
instead of package functions...
because if you want to extend the options for digest mods, you can just
subclass SecureEnough
and overwrite _digestmod
to add more providers.
Encrypting cookies currently happens via a 'global' RSA key for an instance of
SecureEnough()
. [you provide details for it in the __init__()
]
You can use timestamped based app_secrets, obfuscators & rsa keys.
The flow is as such:
Subclass the ConfigurationProvider()
and overwrite the relevant hooks.
The requesting mehtods pass a single argument - timestamp
- which should
give you enough to go on.
Note that app_secret
returns a string, while the obfuscator must return an
object that can obfuscate
and deobfuscate
; and rsa_key
requires an
object that can encrypt
and decrypt
.
This libray provides default functionality through wrapper objects you can
mimic.
Instantiate a SecureEnough()
object, and register the relevant providers
When encrypting data, SecureEnough()
will ask the ConfigurationProvider()
for the approprite keys/secrets for the current time()
. When decrypting
data, SecureEnough()
will ask the ConfigurationProvider()
for the
approprite keys/secrets for the time in the cookie/hash (if there is one).
This flow will allow you to easily create a plethora of site secrets and RSA keys -- as in a new one each day -- which means that while this module is not actually secure, it is Secure Enough for most web applications.
UNTESTED
===================
The following files give an interactive demo:
https://github.com/jvanasco/insecure_but_secure_enough/blob/main/demo.py
https://github.com/jvanasco/insecure_but_secure_enough/blob/main/demo_performance.py
Also note that the github source distribution contains tests.
===================
The timebased providers are largely untested.
insecure_but_secure_enough
is released under the MIT license
FAQs
Lightweight tools for signing and encrypting cookies, urls and stuff. This package isn't really secure, but it is secure enough for most needs.
We found that insecure-but-secure-enough 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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.