Spyderisk / domain-network

Network domain model
Apache License 2.0
1 stars 0 forks source link

Review threats arising from client-service connection authenticity or TW #68

Closed mike1813 closed 10 months ago

mike1813 commented 11 months ago

As discussed in #67, where threats to data flows are caused by issues in Client Channels (client-service relationships) there is a case for restricting the threat so they are only caused by Client Channels representing direct connections (not via transparent proxies) or end-to-end connections (not to/from a transparent proxy).

Loss of Service TW is caused by a malicious service manager/operator or a compromised (hacked) service. In the former case, it is possible for Loss of Service TW to be caused in end-to-end channels only, because the threat is only relevant if the client has the same manager/operator. In the latter case Loss of Service TW is caused in all Client Channels to the service. Where the service is a transparent proxy, these threats only affect the local channels, affecting data flows on end-to-end channels through the proxy but not allowing direct attacks on the end-to-end relationship. Hence Loss of Service TW should not propagate between indirect and direct channels.

Service Impersonation (Loss of Service Authenticity) is caused by an attacker gaining control of the network and diverting client messages, or diverting the client by sending an incorrect service endpoint, e.g., via a phishing attack. In the former case this affects direct channels to the service, as the effect arises in the network. However, if the service is a transparent proxy, what is thereby diverted is the end-to-end communication, so that should also be affected. In the latter case, only end-to-end channels can be affected. Service Impersonation should therefore propagate from direct to indirect channels.

Loss of Anon User TW just means an attacker has network access to the service, which may be true of any service. It therefore affects all direct connections. It should propagate step-wise via transparent proxies towards the back-end service, as if anyone can send messages to the proxy, it will forward them. If the effect is present for a complete chain of connections from the client to the back-end service, the end-to-end connection should also be affected.

Note that Loss of Anon User TW does not imply that an attacker can authenticate or access the service, but it is a prerequisite for malicious access, and sufficient to launch anonymous attacks on a service.

Client Impersonation (Loss of Client Authenticity) is caused when an attacker acquires the means to authenticate to the service as the client. This does not imply they can access the service, however. The ways an attacker can acquire the means to authenticate include (a) access to a service that fails to authenticate clients - so the attacker wouldn't need any credentials at all, (b) access to credentials used by the client that are verified by the service, or (c) authenticated access to a separate service that handles authentication on behalf of the target service. Case (b) includes access to credentials by compromising the client, while case (c) includes authentication by a back-end service enabling authenticated access to a transparent proxy.

Client Impersonation does not propagate between indirect and direct connections. Client Impersonation in an indirect end-to-end connection may be a precursor to an end-to-end Loss of Client TW, enabling Client Impersonation in direct connections from the intervening transparent proxies. Client Impersonation in one of those direct connections does not affect the end-to-end connection, however.

Loss of Client TW is caused by a malicious client user, a compromised (hacked) client, or an attacker with both network access to the service and access to a means of authentication as the client. The first two cases work in the same way as Loss of Service TW, and may affect either direct or indirect channels via transparent proxies. The last case only arises in end-to-end channels which may or may not be indirect.

Where the cause is not a malicious insider, the service may be able to detect that the client is being used by the wrong person (e.g., via biometric profiling) after authentication, so Loss of Client TW implies slightly more than the combination Loss of Anon User TW and Client Impersonation, which are enough to launch authenticated attacks but not to use the service where such checks are possible. Loss of Client TW (by itself) implies access by an imposter. It must be used in conjunction with (possibly contextualised) client attributes to fully model access by a hacked or malicious (but legitimate) client.

If a transparent proxy is compromised, it leads to a Loss of Client TW affecting only the direct channel to the adjacent back-end service, which may or may not be another proxy. The attacker would then have a means to leak data coming from a service and alter data going to a service.

The proxy could also snoop passwords or other credentials (unless protected end-to-end) along with data. However, it doesn't have unfettered access to the back-end service.

Conclusion

We should change threats causing these behaviours so they arise only where they should.

We should change threats caused by these behaviours or the associated TW attributes to ensure they are caused if appropriate while avoiding duplication between direct and indirect channels.

mike1813 commented 11 months ago

Threats causing Loss of Service TW are CC.L.CSHSAC.1, CC.L.CSCCHuoSt.1 and CC.L.CSCCHuSt.1. All are restricted to direct channels to the untrustworthy service, but should apply to any channels.

Threats causing Service Impersonation are CC.AuS.CRoS.3, CC.AuS.CRoSG.3 and CC.AuS.CRoSI.3. All affect direct channels only (via a client path through the network), but the effect should also apply to any associated indirect channels. This is already the case for these threats.

Threats causing Loss of Anon User TW previously worked only for direct channels via transparent proxies, but they have now been replaced by threats representing network access to arbitrary services including transparent proxies, step-wise access via a proxy, and access to the indirect channel if the first and last direct channels are affected. See #64.

Threats causing Client Impersonation (Loss of Client Authenticity) are:

Most of these threats use prohibited links that inhibit the threats unless the service authenticates the client. They don't apply to client-service connections via transparent proxies, so they only affect end-to-end connections, as required.

They also don't affect connections to services that rely on another service for client authentication, including redirection of the client to an OIDC-style authenticator, or forwarding of authentication requests by a transparent proxy to a back end service. In either case, authenticated access (Client TW) to the authenticating service causes Client Impersonation at the dependent service.

CC.AuC.CCCSScS.1 doesn't quite work to cause Client Impersonation in channels via transparent proxies, because there must be both a common client and a 'controls' relationship between the two services. The simplest solution is to remove the inferred 'controls' link (construction pattern CuPvnS+c) so CC.AuC.CCCSScS.1 no longer covers any connections via transparent proxies. This leaves a separate threat CC.AuC.CCCvCCS.1, also added in response to issue #64, to handle those.

The other problem is with CC.AuC.CACHcLSS.1 and CC.AuC.CACHLSS.2, which are also restricted to channels where the service authenticates the client, and (since they require a client attack path) exclude indirect channels via transparent proxies. Evidently, client authenticity is meaningless if the client is such a proxy, so the first restriction is not a problem, although it does mean we will need some other way to represent the effect of a compromised proxy.

The second issue is more problematic. One solution is to link indirect client channels to client attack paths connected to direct channels to/from proxies. However, this would lead to duplicate threat paths from CC.AuA.CCAPNaS.1 or CC.AuA.OCAPNaS.1 via CC.AuA.CCCPCCcS.1 and CC.AuA.CCCv2CCS.1. The best solution seems to be new threats alongside CC.AuC.CACHcLSS.1 and CC.AuC.CACHLSS.2, to cover the case where the end-to-end connection is indirect.

Threats causing Loss of Client TW are:

The first of these excludes channels from transparent proxies because Client Authenticity is meaningless in those cases, but this means there is no path from compromise of the transparent to Loss of Client TW in the direct channel from there towards the back-end service. To fix this, a new threat is needed.

Note that this new threat can lead to Loss of Client TW rather than Client Impersonation because a reverse proxy cannot have an interactive user, so there is no possibility that the intruder could be detected after authentication to the back-end service.

The two insider attacks also exclude channels where the service doesn't authenticate the client. The query injection attack could affect direct or indirect channels, but normally it will be an end-to-end channel because a DB service wouldn't normally act as a transparent reverse proxy. We may want to introduce a modelling error threat to detect where it is used in that way (elevating this assumption to become a domain model restriction). See also

Then all threats caused by Client Authenticity or TW, Service Authenticity or TW, and Client-Service Accessibility must be made consistent with the above.

mike1813 commented 11 months ago

The change to CC.L.CSHSAC.1 revealed a small problem.

Removing the mandatory ClientChannel-channelVia-ServiceChannel link means the ClientChannel is no longer restricted to be a direct connection. However, the threat originally specified a ClientChannel-viaSubnet-LogicalSubnet link. It turns out this is not necessary, as the ProcAccess-accessToService-ClientChannel link ensures that the ClientChannel is used in the context where the service has been compromised (so addressing cases where the service host may be mobile).

But investigating this aspect led to a couple of surprises. First, this link is only created for indiret channels (by CCCvCCvLS+vLS) to subnets visited en-route to the first transparent proxy. This means restoring the ClientChannel-viaSubnet-LogicalSubnet link to CC.L.CSHSAC.1 could suppress that threat entirely.

Other uses of this link are:

Because indirect channels are not fully connected to all potential subnets, the first three cases won't work properly for indirect client-service relationships. Pattern CCCvCCvLS+vLS should be changed so links are created to all subnets used. However, that would mean P.V.CCCSACvLS.2 could form duplicate threats from the indirect and last direct channel to the service.

The best solution: remove the viaSubnet link from P.V.CCCSACvLS.2 and add a prohibited usesViaProxy link so this threat only arises in connection to a direct channel. If an attacker could authenticate as an indirect client, then CC.AuC.CCCvCCS.1 ensures they can attack from a local subnet between the last transparent proxy and the service. This prevents CCCvCCvLS+vLS changes from producing spurious duplicate threats elsewhere.

mike1813 commented 11 months ago

CC.L.CSCCHuoSt.1 and CC.L.CSCCHuSt.1 were originally restricted to direct connections, so this restriction (a link from the Client Channel to a mandatory Service Channel) was removed.

mike1813 commented 11 months ago

CuPvnS+c renamed CuPvnS+n, and the constructed 'Service-controls-Proxy' link removed, leaving only Client-noAuthN-Proxy.

mike1813 commented 11 months ago

Adding new threats alongside CC.AuC.CACHcLSS.1 and CC.AuC.CACHLSS.2 proved too difficult. Instead, their scope was expanded to include indirect client-service relationships.

This can be done by adding construction pattern CCCCAP+ch after the existing CCSCAP+ch. The new pattern adds a 'channelVia' link from each indirect client channel to each client attack paths already linked (by CCSCAP+ch) to a channel via a proxy.

ClientChannel-channelVia-ClientAttackPath links are used in CC.AuC.CACHcLSS.1 and CC.AuC.CACHLSS.2, so adding these links from indirect channels opens up the threats so they can address indirect as well as direct channels.

It is also used in CC.AuA.CCAPNaS.1 and CC.AuA.OCAPNaS.1, where we don't want to open the threats up in the same way. This is because those threats represent the process of sending an unauthenticated message to the service, which propagates to the end-to-end channel via CC.AuA.CCCPCCcS.1 and CC.AuA.CCCv2CCS.1. To prevent this, a prohibited Client-usesViaProxy-Service link is added.

mike1813 commented 11 months ago

CC.R.HuoStCCCS.1 or CC.R.HuStCCCS.1 restricted by adding a prohibited proxyAuthN link, and removing links from the Client Channel to a mandatory Service Channel node.

mike1813 commented 11 months ago

Review of threats caused by Service Authenticity:

The first two threats affect data flow intermediaries, so should arise for any connection including those via transparent proxies.

The other two threats are caused only by end-to-end connection. The first is constructed in that way, while the second should never be found for a transparent proxy service because such a service should never control anything except another transparent proxy.

Required actions:

mike1813 commented 11 months ago

Review of threats caused by Service TW:

These threats differ from those caused by Service Authenticity because the real service is involved. An imposter service cannot block access to the real service, nor access encryption keys. The real service can block access, and if it is the data flow source or destination, it can alter/intercept even encrypted data (unless homomorphic encryption is used).

The first two threats should be restricted to end-to-end client channels arriving at the service, so as not to create a duplicate from the channel from the last transparent proxy. The others need no such restriction.

Required actions:

mike1813 commented 11 months ago

Review of threats caused by Client Authenticity:

The first of these only makes sense for end-to-end connections. If a transparent proxy were compromised, it would be able to access its back-end service (which may be another proxy), but not as the ultimate client.

The other three threats should apply to all direct or indirect connections. In practice, direct connections are sufficient because a loss of authenticity propagates from the end-to-end connection via CC.AuC.CCCvCCS.1, and loss of accessibility propagates to the end-to-end connection via CC.AX.CCCvCCS.0.

Required changes: none.

mike1813 commented 11 months ago

Review of threats caused by Client TW:

Required changes:

mike1813 commented 10 months ago

Initial tests revealed a couple of bugs.

Pattern CCCSScS had the prohibited proxyAuthN link in the wrong place, suppressing threats to connections from transparent proxies, when it should have prevented threats from those connections. Threat CC.L.CSHSAC.1 wasn't updated correctly - the mandatory service channel wasn't removed as intended.

Now fixed, so all the above changes have been made in branch 65.

mike1813 commented 10 months ago

Regression tests revealed that the modelling error(s) aren't working quite as expected.

In test case Test04d C-P-X-S-Implicit (attached), the modelling error P.E.Pc-uCpS.9 is found as expected. This arises because the transparent proxy P2 is also controlled by authentication service X4. That is inconsistent, as a transparent proxy should not be authenticating clients, not even by redirection to an authentication service.

However, we also get the new modelling error P.E.Pc-pPpmS.9, which catches cases where a transparent proxy controls another process. That is also inconsistent, because access to a service can only be controlled by another service that authenticates clients, either locally or by further redirection.

In this case, the modelling error says P2 is controlling X4, but in fact the relationship is the other way around. It looks like a copy and paste error durnig the creation of the threat pattern.

Required changes:

mike1813 commented 10 months ago

Pattern CCCSScS had the prohibited proxyAuthN link in the wrong place

Actually, the proxyAuthN link already included in pattern CCCSScS was in the right place. There was a proxyAuthN link missing which had to be added, but the existing link should not have been deleted.

mike1813 commented 10 months ago

The modelling errors got into a bit of a mess. We now have:

During development of these threats to client-service relationships it was assumed that a reverse proxy will either authenticate the client before forwarding subsequent requests in the same session, or forward authentication requests to back-end services (so they control the proxy). It is not clear whether the solutions adopted rely on this assumption. A simple test case that mixes the two cases seems to work OK, but more analysis and testing is needed to confirm this would hold in more complex system models. Given that, the first modelling error has been retained.

The second modelling error is needed. A transparent proxy is controlled by the back-end services, so having access to it controlled by anything else would create a conflict. The resulting system model would be at best ambiguous as to how this can be resolved so we need a modelling error to detect and flag that situation.

The other three are needed because a transparent proxy doesn't authenticate clients, so it has no basis on which to make access control decisions for any other service (or host or network). Back-end services accessed via a transparent proxy could do this, but not the proxy itself.

mike1813 commented 10 months ago

The new threat for Loss of Client TW in a channel from a transparent proxy is CC.R.CAPHcLSS.1. It is similar to CC.AuC.CACHcLSS.1 except instead of a prohibited 'Client-noAuthN-Service' link it has a necessary 'Client-proxyAuthN-Service' (meaning that the Client is a transparent proxy for the back-end Service). In addition, the ClientAttackPath has a 'channelTo' link to the Service.

mike1813 commented 10 months ago

Changes now addressed as described in revised comments, fixing problems found in regression tests so this issue can be closed again.

mike1813 commented 10 months ago

Reopening once again. One more issue found in the regression test. Loss of Service TW shouldn't propagate between direct channels and indirect end-to-end channel, as this leads to duplicate threat paths.

The reason this was missed is because if Loss of Service TW arises due to malicious control of the service, we assumed (rightly) that direct and indirect channels to the service would be affected. However, it was wrong to conclude this means it is OK to propagate Loss of Service TW from direct channels to indirect channels. If the hacked service is a transparent proxy, the indirect channel isn't to the service, so propagation to the indirect channel creates a new, duplicated threat path.

The solution is to revert changes in CC.L.CSHAC.1, CC.L.CSCCHuoSt.1 and CC.L.CSCCHuSt.1 that add optional threat effects where there is an indirect channel. The changes enabling indirect channels to be affected are still needed, however.

In addition, the descriptions given above should be fixed.

mike1813 commented 10 months ago

Fixed in branch 65, and descriptions above made consistent with what is needed.