Skip to content

Commit

Permalink
address security findings (#875)
Browse files Browse the repository at this point in the history
* Address security findings

* javascript/InsecureHash
* python/Ssrf

---------

Signed-off-by: Richard Gebhardt <[email protected]>
  • Loading branch information
gebhardtr authored Mar 26, 2024
1 parent 586a06a commit 89521a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { createHash } = require("crypto");

module.exports = (env) => {
const hash = createHash("md5");
const hash = createHash("sha256");
hash.update(JSON.stringify(env));

return hash.digest("hex");
Expand Down
36 changes: 33 additions & 3 deletions tools/authz/validate_ams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
# NOTE: require the sso.stage credentials

import os
import re
from datetime import datetime, timedelta
from http import HTTPStatus
from urllib.error import URLError
from urllib.parse import urlsplit, urlunsplit

import requests

AUTHZ_SSO_PATTERN = r"^sso.(.+\.)?redhat.com$"
AUTHZ_API_PATTERN = r"^api.(.+\.)?openshift.com$"


class AuthzURLError(URLError):
pass


class Token:
def __init__(self, client_id, client_secret) -> None:
Expand All @@ -23,11 +33,22 @@ def refresh(self) -> None:
"scope": "api.iam.access",
}

url = urlsplit(os.environ['AUTHZ_SSO_SERVER'])
url = url._replace(path="/auth/realms/redhat-external/protocol/openid-connect/token")

if not re.search(AUTHZ_SSO_PATTERN, url.netloc):
raise AuthzURLError(
f"Authz SSO URL host ('{url.netloc}') must match '{AUTHZ_SSO_PATTERN}'"
)

if url.scheme != "https":
raise AuthzURLError(f"Authz SSO URL scheme ('{url.scheme}') must be 'https'")

r = requests.post(
os.environ['AUTHZ_SSO_SERVER']
+ "/auth/realms/redhat-external/protocol/openid-connect/token",
urlunsplit(url),
data=data,
)

data = r.json()
self.access_token = data["access_token"]
expires_in = data["expires_in"]
Expand All @@ -45,8 +66,17 @@ def get(self) -> str:
def get_ams_org(rh_org_id: int) -> str:
params = {"search": f"external_id='{rh_org_id}'"}

url = urlsplit(os.environ['AUTHZ_API_SERVER'])
url = url._replace(path="/api/accounts_mgmt/v1/organizations")

if not re.search(AUTHZ_API_PATTERN, url.netloc):
raise AuthzURLError(f"Authz API URL host ('{url.netloc}') must match '{AUTHZ_API_PATTERN}'")

if url.scheme != "https":
raise AuthzURLError(f"Authz API URL scheme ('{url.scheme}') must be 'https'")

r = requests.get(
f"{os.environ['AUTHZ_API_SERVER']}/api/accounts_mgmt/v1/organizations",
urlunsplit(url),
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {my_token.get()}",
Expand Down

1 comment on commit 89521a4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClamAV Virus Definition DB Files:
----
total 228448
-rw-r--r--  1 root root 170479789 Mar 26 06:08 main.cvd
-rw-r--r--  1 root root        69 Mar 26 06:08 freshclam.dat
-rw-r--r--  1 root root  63143246 Mar 26 06:08 daily.cvd
-rw-r--r--  1 root root    289733 Mar 26 06:09 bytecode.cvd
drwxr-xr-x 16 root root      4096 Mar 26 18:55 ..
drwxr-xr-x  2 root root      4096 Mar 26 18:55 .
----
File: /var/lib/clamav/bytecode.cvd
Build time: 27 Feb 2024 10:37 -0500
Version: 335
Signatures: 86
Functionality level: 90
Builder: raynman
MD5: 16d388f042f5c44628a66228df427c20
Digital signature: 7fD3mweaw4tqQH9Dl7ZewBLXZBSrLKX5no/rYN/6NQBmhnWUyTBt3uzd7ZjEnIT5yN1ygLwsDcuzoKRoA+syrfk3PcDHf5/h6Wb/d8uikXSALygH5VYAPo2ksV5Pitn3reECJ90q2m9m0CH2VpT1tDkkcVi05LLV5PwBle2Ufpe
Verification OK.
----
File: /var/lib/clamav/daily.cvd
Build time: 25 Mar 2024 04:30 -0400
Version: 27225
Signatures: 2056578
Functionality level: 90
Builder: raynman
MD5: f2f896a103bcf92487d93e0dab11ff3b
Digital signature: yA+0wnfHmCfEzidE1Si9rcF6V7LsZFk82JXowGx336Zf3BGrVN6/bvS65y7mBqCvHComIZTLeU9yAGXoJ9P3fEMkzu1muVy1rUMYvJtY/cXB6Qm8GSABAsI6WmVkOm24n4GrfrImohGlj4k2K+LFPu0VhqG8La5o7Dgt6bFF7Rd
Verification OK.
----
File: /var/lib/clamav/main.cvd
Build time: 16 Sep 2021 08:32 -0400
Version: 62
Signatures: 6647427
Functionality level: 90
Builder: sigmgr
MD5: 137eccce31aacb21b5a98bb8c21cefd6
Digital signature: twaJBls8V5q64R7QY10AatEtPNuPWoVoxTaNO1jpBg7s5jIMMXpitgG1000YLp6rb0TWkEKjRqxneGTxuxWaWm7XBjsgwX2BRWh/y4fhs7uyImdKRLzQ5y8e2EkSChegF/i8clqfn+1qetq9j4gbktJ3JZpOXPoHlyr2Dv9S/Bg
Verification OK.
----
Scanning Results:
ClamAV 1.0.5/27225/Mon Mar 25 08:30:27 2024
LibClamAV Warning: Max file-size was set to 4194304000 bytes. Unfortunately, scanning files greater than 2147483647 bytes (2 GiB - 1) is not supported.

----------- SCAN SUMMARY -----------
Known viruses: 8688428
Engine version: 1.0.5
Scanned directories: 31765
Scanned files: 195342
Infected files: 0
Data scanned: 6530.23 MB
Data read: 3427.26 MB (ratio 1.91:1)
Time: 1417.966 sec (23 m 37 s)
Start Date: 2024:03:26 18:57:29
End Date:   2024:03:26 19:21:07

Please sign in to comment.