Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make fips compliant by replacing md5 with sha256 in postgres and usedforsecurity=False for python md5 #21014

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset/key_value/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def decode_permalink_id(key: str, salt: str) -> int:


def get_uuid_namespace(seed: str) -> UUID:
md5_obj = md5()
md5_obj = md5(usedforsecurity=False)
md5_obj.update(seed.encode("utf-8"))
return UUID(md5_obj.hexdigest())

Expand Down
2 changes: 1 addition & 1 deletion superset/migrations/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def table_has_column(table: str, column: str) -> bool:

uuid_by_dialect = {
MySQLDialect: "UNHEX(REPLACE(CONVERT(UUID() using utf8mb4), '-', ''))",
PGDialect: "uuid_in(md5(random()::text || clock_timestamp()::text)::cstring)",
PGDialect: "uuid_in(sha256(random()::text || clock_timestamp()::text)::cstring)",
}


Expand Down
2 changes: 1 addition & 1 deletion superset/utils/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def md5_sha_from_str(val: str) -> str:
return hashlib.md5(val.encode("utf-8")).hexdigest()
return hashlib.md5(val.encode("utf-8"), usedforsecurity=False).hexdigest()

Check failure

Code scanning / CodeQL

Use of a broken or weak cryptographic hashing algorithm on sensitive data High

Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (id)
is used in a hashing algorithm (MD5) that is insecure.
Sensitive data (certificate)
is used in a hashing algorithm (MD5) that is insecure.


def md5_sha_from_dict(
Expand Down
4 changes: 2 additions & 2 deletions superset/utils/public_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@


def compute_func_hash(function: Callable[..., Any]) -> str:
hashed = md5()
hashed = md5(usedforsecurity=False)

Check warning on line 43 in superset/utils/public_interfaces.py

View check run for this annotation

Codecov / codecov/patch

superset/utils/public_interfaces.py#L43

Added line #L43 was not covered by tests
hashed.update(str(signature(function)).encode())
return b85encode(hashed.digest()).decode("utf-8")


def compute_class_hash(class_: Callable[..., Any]) -> str:
hashed = md5()
hashed = md5(usedforsecurity=False)

Check warning on line 49 in superset/utils/public_interfaces.py

View check run for this annotation

Codecov / codecov/patch

superset/utils/public_interfaces.py#L49

Added line #L49 was not covered by tests
public_methods = sorted(
[
(name, method)
Expand Down
Loading