-
Notifications
You must be signed in to change notification settings - Fork 182
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
Cannot override findings, threats remain, DFD impacted, exception thrown for overrides len > 1 #222
Comments
Hi, I looked at the code and a Finding requires a corresponding threat. The error you encountered happens because later pytm checks if two Findinds cover the same Finding(
id="DE01",
CVSS="9.1",
response="""**To Mitigate**: run a memory sanitizer to validate the binary""",
threat_id="loL"
),
Finding(
id="AC05",
CVSS="9.2",
response="""**To Mitigate**: run a memory sanitizer to validate the binary""",
threat_id="loL2 "
),
Finding(
id="DE03",
CVSS="9.3",
response="""**To Mitigate**: run a memory sanitizer to validate the binary""",
threat_id="loL3"
),
Finding(
id="CR06",
CVSS="9.4",
response="""**To Mitigate**: run a memory sanitizer to validate the binary""",
threat_id="loL4"
)
] @izar from the code I currently don't see why there is this check for the |
Hm, let me take a look and get back to you ASAP. Thanks for the report! |
@raphaelahrens I again with
Thankfully this did process fine, no exception returned about Finding having more than one override as detailed in the opening issue description. Checked the DFD and its still has invalid elements, one for each Finding: From what I can tell the https://github.com/izar/pytm/blob/master/pytm/pytm.py#L661-664 |
Can you share your full model ? I am a bit thrown by the "invalid" elements out there. |
Sure no problem, to keep things simple I have used only the example provided tm.py with the override snippet taken from your README here. Note:
Report and associated DFD are generated using commands from README here:
Using these commands and |
Ok, so this is functionality that I have not used before. If I understand @nineinchnick test code correctly, it is supposed to work on user-supplied Threat objects. I see no reason why it shouldn't work on library based threats, so I'll pursue that together with the spurious element appearing in the DFD. I think I know where that one is coming from. Please stay tuned. |
I found the DFD problem. Can you submit a PR with your change, and I'll fix
the DFD on my side?
…On Tue, Oct 24, 2023 at 11:19 AM Michael McAleer ***@***.***> wrote:
Quick update, I was able to get override threats by changing this
condition:
https://github.com/izar/pytm/blob/5ec33e15cb263504f0f8126d745e7f0b8c7dc8f6/pytm/pytm.py#L804-L806
To:
if not t.apply(e) or t.id in override_ids:
continue
This thought behind this is if the threat does not apply() or the threat
id is in the list of override ids, we can continue to the next threat in
the threat list. Using and here means that if a threat does apply() it
doesn't matter if it is in the override list, its processed as a new
finding anyway and override ignored.
This does not fix the invalid elements in the DFD however, that issue
persists.
—
Reply to this email directly, view it on GitHub
<#222 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC2BAITOJHWMH3JVB7JXV3YA7MADAVCNFSM6AAAAAA6L5TQTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZXGQ3DINJVHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@MichaelMcAleer your change makes the test for the feature fail. I think we may need @nineinchnick input here, lest we break the intent of the feature. |
Thanks for the update @izar, I was just working on it there and adding a way to track overridden threats with finding responses, they would be useful to output in generated report. I'll wait for input from @nineinchnick before continuing. Whilst there is a pull request open with a fix incoming, I spotted something else in https://github.com/izar/pytm/blob/5ec33e15cb263504f0f8126d745e7f0b8c7dc8f6/pytm/pytm.py#L1877-L1881 It should be:
|
Can you try to create Findings for overrides with only the |
Tried again @nineinchnick where Findings for overrides do not have an Another thing I tried was to manually set So far the only thing I have been able to do to have element threats overriden is to change the condition whereby a threat is evaluated from: https://github.com/izar/pytm/blob/5ec33e15cb263504f0f8126d745e7f0b8c7dc8f6/pytm/pytm.py#L804-L806 To:
The reasoning being we can continue to the next threat in the loop because the threat id is in the list of override ids. I do want to point out that I view this as an over simplified solution, I would prefer to track the overridden threats in something like |
Ok let me try to run your example and debug it. Thanks for your patience on this! |
As a workaround, you could try setting the |
This is definitely a bug. We should avoid creating such invalid elements in the first place. I left a comment about that in #223. |
I am on PTO so responses will be delayed for the next week. I found another bug, when overriding findings, the findings output do not record the CVSS score. For example, using the following overrides:
The related findings in the JSON output do not have the CVSS score set:
Note: If the
|
The CVSS score is not being set because in the example code Finding(
id="66",
threat_id="CR06",
CVSS="9.3",
response="""**To Mitigate**: run a memory sanitizer to validate the binary""",
) the member variable |
Using the included tm.py as an example here, not the code snippet from the README under 'creating a threat model'.
When I use
tm.py
to build an example report and DFD everything is fine. When I try to add a single override as demonstrated in the README section overrides the threat is still listed under the dataflow foruser_to_web
, it is not overridden.The DFD generated from this threat model now has an
invalid
element because theFinding
does not realise what element is referring to when it is initialised. Given theFinding
is listed in the overrides for the dataflow it should know what element it is referring to.In addition to this, if an attempt is made to list more than one
Finding
inoverrides
, which expects alist
ofFindings
invarFindings()
, an exception is thrown:The example provided in the README uses threat SID
INP02
which isn't a threat identified for that dataflow, I have usedDE01
on its own to get the result above with invalid element in the DFD and remains as an active threat in the generated report.When overriding multiple threats I used threats identified in the report to ensure relevance and uniqueness. The
user_to_web
overrides
is as follows in my alteredtm.py
:The text was updated successfully, but these errors were encountered: