-
Notifications
You must be signed in to change notification settings - Fork 1
/
property.py
65 lines (57 loc) · 1.92 KB
/
property.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from dataclasses import dataclass
import requests
from report import Reporter
@dataclass
class Submission:
src: str
form_name: str
class AppPropertyScanner:
def __init__(
self,
session: requests.Session,
reporter: Reporter,
base_url,
app_key,
user=None,
api_token=None,
):
self.session = session
self.reporter = reporter
self.base_url = base_url
self.app_key = app_key
if user and api_token:
self.session.auth = (user, api_token)
def _get_properties(self, url):
properties = self.session.get(url)
try:
properties.raise_for_status()
properties = properties.json()["keys"]
except:
properties = []
return properties
def scan(self, db):
properties = self._get_properties(
f"{self.base_url}/rest/atlassian-connect/1/addons/{self.app_key}/properties"
)
if not properties:
# try confluence next
properties = self._get_properties(
f"{self.base_url}/wiki/rest/atlassian-connect/1/addons/{self.app_key}/properties"
)
if not properties:
return
for prop in properties:
try:
prop_res = self.session.get(prop["self"]).json()
except:
continue
for canary, submission in db.keys():
if canary in prop_res["value"]:
self.reporter.add_vuln(
check_name="Secret scanner",
description=f"Found secret {canary} in {prop_res['self']}.",
recommendation="Store the secret server side, since app properties can be accessed by anyone.",
proof=f"Submitted in {submission.src}",
severity="High",
)
break