SKY-D383 · Security in code
RSA key size defaults below 2048 bits
Skylos flags a Django form default or a registered Oslo integer option that can give openssl genrsa a key size below 2048 bits. The finding points to the line that sets the default.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- Undersized RSA key generation
Why it matters
A mailbox with no saved key size can inherit a 1024-bit default. OpenSSL then creates a weaker signing key for that mailbox.
What Skylos flags
from django import forms class KeyPolicy(forms.Form): bits = forms.IntegerField(initial=1024) def configured(name, settings): if name not in settings: return KeyPolicy.base_fields[name].initial return int(settings[name])from django.db import modelsfrom policy import configured class Mailbox(models.Model): key_bits = models.PositiveIntegerField(null=True) def signing_bits(self, settings): size = self.key_bits if size is not None: return size return configured("bits", settings)import subprocessfrom models import Mailbox def generate_key(mailbox: Mailbox, settings, key_file): size = mailbox.signing_bits(settings) subprocess.run(["openssl", "genrsa", str(size)], stdout=key_file, check=True)What Skylos leaves alone
from django import forms class KeyPolicy(forms.Form): bits = forms.IntegerField(initial=2048) def configured(name, settings): if name not in settings: return KeyPolicy.base_fields[name].initial return int(settings[name])Why Skylos leaves it alone
When the mailbox has no saved size and the settings omit bits, the form supplies 2048.
How Skylos decides
- Finds a positive default below 2048 on a Django form field or a registered Oslo integer option.
- Follows the value through settings reads, including Django model methods that fall back to the form when a saved value is missing.
- Reports the default when it can reach the key-size argument of
openssl genrsa. A fixed 4096-bit override on that path clears the finding.
How to fix it
Set the default to at least 2048 bits. Apply the same minimum to user-supplied sizes. Replace any undersized keys already in use.
When it can be wrong
- A deployment can require a larger override through settings that Skylos cannot see. Check whether a fresh installation can still use the weak default.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
If every supported deployment enforces a safe size, add
# skylos: ignore[SKY-D383]to the flagged field or option and record where that minimum is enforced.