An interaction between a user and a system in cyberspace requires, in most cases, the creation of a secure communication channel between them. In this context, we usually think about a device
A acting on behalf of the user and a device
B serving as a gateway to the system. However, in reality, we have to deal with three participants: a user, a device
A, and a device
B. Moreover, the user can be passive only when there is no significant threat to allow
A to act on behalf of the user without their control. In other cases, explicit consent of the user is necessary. If personal data are exchanged between
A and
B (as is usually the case), then the user’s consent is mandatory according to data protection regulations such as European GDPR [
1]. Moreover, the communication architecture should guarantee
security and privacy by design: only those parties should be able to read the data exchanged, which are indicated by the user’s consent.
1.1. PAKE—Password-Authenticated Key Exchange
The idea of PAKE (Password-Authenticated Key Exchange) is to enable users’ consent based on password presentation while binding this consent to a specific communication session in a cryptographic way. A PAKE protocol executed by devices A and B determines a session key K so that
A and B can calculate K, but no other party with access to the interaction between A and B can derive K.
The protocol fails unless the same password, , is used by A and B.
A party observing the interaction cannot derive password by an offline analysis or by an active man-in-the-middle attack, where the adversary manipulates the messages exchanged (potentially leading to protocol abortion by the legitimate participants).
A PAKE protocol can be run independently or it can be integrated into a protocol stack where, for example, the identity of devices
A and
B is checked based on the possession of secret keys. There is no universal scenario indicating which party initiates the protocol, as this may depend on an application.
Figure 1 shows the case where PAKE is used to authenticate a user and create a connection instead of a traditional (password, login) mechanism. The difference is that the password is already used at the stage of creating a connection and, due to the properties of the PAKE protocol, no shared key is established if different passwords are used by protocol participants. Typically, an execution of PAKE is initiated by a user who wishes to enter their account in the system. In this scenario, a phishing attack would fail: the attacker providing the phishing page would not establish a connection to the victim user, unless the attacker already knows the user’s password.
Figure 1.
Example application scenarios for PAKE: A user holding a password connects to a remote system, where a database stores a password for each user. The password is entered by the user on the local computer, while in the remote system, it is fetched from a database by the gateway unit of the system. The connection succeeds if and only if the passwords on both sides match. If the connection fails, the communicating parties learn only that the passwords used do not match.
Figure 1.
Example application scenarios for PAKE: A user holding a password connects to a remote system, where a database stores a password for each user. The password is entered by the user on the local computer, while in the remote system, it is fetched from a database by the gateway unit of the system. The connection succeeds if and only if the passwords on both sides match. If the connection fails, the communicating parties learn only that the passwords used do not match.
Another application case to mention is an e-booth for automatic passport control (see
Figure 2).
Several password authentication protocols have been developed over the decades. For a general discussion on the topic, design trends, and reality issues, see [
2]. Some of the protocols became widespread, such as the PACE protocol [
3] adopted by the ICAO for travel documents [
4], and later by the European Union as a standard for personal identity documents in the Union.
1.2. CPace Protocol
In 2020, CPace (see the Internet Draft:
https://www.ietf.org/archive/id/draft-irtf-cfrg-cpace-11.html (accessed on 18 August 2025) [
5]) has been selected by the IRTF Crypto Forum Research Group (CFRG) as the recommended PAKE protocol. CPace is a symmetric protocol. This means that it is not specified in advance who is the protocol initiator, and that the operations performed on either side are the same; only the parameters change. (This is not the case for the widely used PACE protocol for biometric passports, where the passport initiates the interaction and where the roles of the passport and the reader are different.) Therefore, although CPace is intended to be used for interaction between a user device
and a server (maybe a remote one), the description of the protocol frequently refers to party
A and party
B.
CPace is presented in
Table 1. As one can see, CPace is an extremely simple protocol with only 2 messages exchanged between the communicating parties. This is the minimal number of messages for a scenario in which each party can randomize the final key and where a low-entropy password is the only secret shared by the communicating parties.
The first important feature of CPace is that the communicating parties derive a shared group generator
G using the shared password. This is a feature common with the seminal SPEKE protocol [
6] and PACE in the version PACE IM (Integrated Mapping) [
4]. In the case of SPEKE, the generator is a hash of the password, which leads to protocol weaknesses. PACE IM and CPace follow a different strategy: for each execution of the protocol, the generator is different. PACE IM creates the generator by hashing two random nonces, one of which was earlier transmitted by the user’s device in the form of a ciphertext obtained with an encryption key derived from the password. CPace is simpler and does not require extra messages: the generator
G is derived as
where
is a procedure that applies a hash function specified by the parameter
to the input obtained by concatenating the password
, the channel identifier
, and the unique session identifier
. The parameters
and
are obtained from a higher-level protocol. As the parameters
and
must not repeat, each protocol execution refers to a different generator
G, and due to the properties of the hash function, it is computationally infeasible to derive the discrete logarithm of
G with respect to the standard generator
P of the group used (that is, in the additive group notation, a scalar
k such that
). Similarly, it is computationally infeasible to derive any relationship between the discrete logarithms of
G’s from two different protocol executions.
Recall that in the widely used PACE GM (General Mapping) protocol, there is a Diffie–Hellman key exchange based on a standard generator that produces an element h. In turn, h is used to determine (according to the original multiplicative group notation), where s is a random nonce generated by the passport and encrypted using the password-derived key. Finally, no one knows the discrete logarithm of ; element depends on the password, but the procedure is more complicated and less resistant to implementation attacks.
Note that an observer cannot generate G from the CPace protocol; however, they can derive a candidate G for each possible password, provided that has access to and . Since passwords have low entropy, this is feasible. (An interested reader may notice that this is also possible for the already mentioned PACE IM but not for PACE GM.)
The next stage of the algorithm is a Diffie–Hellman key exchange and its result is a shared master key K. For Diffie–Hellman key exchange, the critical point is to choose the scalars and . The function is used for this purpose. It intends to choose a scalar smaller than the group order uniformly at random. According to the specification, is a function returning a representation of an integer (referred to as a “scalar” from now on) appropriate as a private Diffie-Hellman key for the group, and some deviations from uniform distribution are allowed.
Once the master key K is created, on each side independently, the parties derive the key by hashing K together with the parameters that may be called an interaction transcript. This should prevent relay attacks; the key is the same for parties A and B, if they have the same view of the protocol execution. However, if the views differ, then the keys derived on both sides should differ according to the collision resistance of the hash function.
The key is called the “intermediate session key’ as the higher-level protocol can derive other keys based on the shared key .
Note that in the above-presented version, CPace does not contain any key confirmation mechanism. However, the authors discuss extensions of the basic scheme in this direction. Typically, key confirmation is based on a tag created by a deterministic algorithm, so that a valid tag can be created only by a party holding the right key, and where the tag does not enable to derive the key used to create the tag. Since there is not much room for attacks via key confirmation tags, we will concentrate on the main part of CPace.
In this paper, we do not need to go into detail about why the CPace construction is sound, what the backgrounds are for particular design choices, etc. The reason is that our goal is to check its resilience to implementation attacks and to find what can go wrong.
1.3. Security Analysis of CPace
Proving the security of a PAKE protocol in a real-world setting is a tricky issue. First, the number of attack scenarios is quite large. They may involve situations such as concurrent execution of the same protocol by a user with different services, exploiting false executions, small errors when inputting the passwords, etc. The adversary is not always external: for example, it may happen that a card reader B learns the password used by card A during a legitimate interaction, and later the operator of B uses to track A interacting with other card readers through a wireless radio channel.
Many problems may arise when a PAKE protocol is embedded in a protocol stack. A PAKE protocol that is secure in a standalone scenario can become insecure after such an embedding, or, at least, the security arguments no longer hold (this is the so-called universal composability problem).
The complexity of the security analysis of a PAKE protocol grows rapidly with the complexity of the protocol. It is a real challenge to make it complete in the real sense and not only according to a selected abstract model. Even for relatively compact protocols such as PACE, analyzing all options may become very tedious [
7].
From the point of view of security analysis and immunity against attacks, the simplicity of CPace is a great advantage. Note that essentially the only messages exchanged between the parties executing CPace are two random group elements . Their distribution does not depend on the password for cyclic groups and uniformly chosen and . So, intuitively, an external observer has neither any usable source of information on nor an opportunity for a man-in-the-middle attack. The simplicity of the protocol also reduces the number of implementation errors that may occur. Such errors can be very subtle, and, in particular, they can result from efficiency optimization.
The most critical issue concerning formal security proofs for CPace is that it should be considered not as a standalone protocol but as a protocol embedded in a larger system. This issue has been reflected in the criteria in the IETF selection process. Repeating security proofs for each particular implementation case can be avoided if the protocol analyzed fulfills the properties of universal composability (UC) [
8] (see also the IACR technical report [
9]). UC means that, from a security point of view, a real implementation of the protocol (in our case, the execution of CPace) can be replaced by an ideal functionality that realizes the goal of the protocol when interacting with the environment. In our case, the ideal functionality assigns a shared secret session key
K to the communicating parties if and only if they have the same password. Fine issues concern the abilities of the adversary and the feedback received by the adversary from the ideal functionality. There are subtle differences between the original framework from [
8] and the papers that examine the universal composability of CPace.
In [
10] (see also [
11]), the relaxed PAKE functionality and the lazy extraction PAKE functionality are introduced. CPace falls into the category of protocols for which universal composability with regard to the lazy extraction model has been achieved. The paper [
12] shows universal composability for CPace, however, in the AGM (Algebraic Group Model). The AGM imposes restrictions on the group elements returned by the adversary, requiring them to be algebraic in the base elements (that is, in additive group notation, a linear combination of the base elements). In particular, note that a solution to the DH problem for
and
cannot be expressed as an algebraic expression in
and
.
An in-depth analysis of CPace in the context of algebraic implementation details versus universal composability can be found in [
13] (see also the IACR report [
14]). This analysis concerns, for example, issues such as collisions of the mapping deriving the elliptic curve points by the function
and the elliptic curve groups of non-prime order.
In a more recent paper [
15], the authors investigated the universal composability property of a version of the protocol in which participants do not have to agree on the shared data before entering the protocol.
1.4. Security Analysis vs. Malicious Implementations
Apart from the threats typically considered in the cryptographic literature, it is necessary to take into account subversion attacks. The goal of such attacks is to bring some advantage to the adversary (e.g., to allow tracing a user) while mimicking honest protocol execution. Thus, a user may believe that a strong cryptographic protocol with firm security and privacy guarantees is executed, while in reality, it is a different protocol with backdoors created for the adversary’s advantage.
An implementation can be subverted on purpose, as a part of a development process, or enabled by a security gap in a supply chain [
16]. In the case of a software implementation, subversion is also possible during the lifetime of the product, carried out by some malware that has penetrated the operating system. Typically, attacks of this type use asymmetric cryptography: the implementation uses the adversary’s asymmetric key that functionally corresponds to the public key. Thus, extracting this key from an infected implementation is not sufficient to take advantage of the attack: for this purpose, it is necessary to use a matching key (functionally a private asymmetric key) kept by the adversary. In addition, manipulations should be designed in such a way that even knowledge of this “public key” does not allow one to determine, based on the generated output, whether another instance of the device or software is also subverted.
Initially, attacks of this type were known as kleptographic attacks (see the seminal work [
17]). Typically, kleptography utilizes random values used by the attacked cryptographic scheme. Many schemes that use the discrete logarithm problem, as well as key generation in the RSA algorithm, are vulnerable to kleptographic attacks (cf. [
18,
19]). Post-quantum schemes are also unsafe in this regard [
20,
21].
In summary, a subverted implementation runs the protocol in a malicious way so that an adversary has some advantage while the attack remains undetected. In particular, black box analysis does not allow external observers to distinguish between a fair implementation and a subverted one—the outputs generated by both implementations are perceived by the observers as having the same probability distributions. Only possession of the adversary’s private key allows access to the kleptographic channel. Therefore, kleptographic attacks would be particularly difficult to detect in the case of embedded devices, such as secure elements or smart cards.
It is known that security analysis from the point of view of universal composability does not address the issues of subversion attacks. In practice, full protection against subversion attacks is hardly possible. Fortunately, in some cases, subversion resilience and universal composability can be achieved at the same time. The paper [
22] (see also [
23]) achieves this by sanitizing a PAKE protocol based on oblivious transfer. The paper [
24] achieves the same by enhancing CPace with reverse firewalls. For each protocol participant, the authors of [
24] add a reverse firewall that randomizes the elements
and
. This reverse firewall chooses
at random and raises
and
to the power
before forwarding them. As a consequence, the elements
,
cannot be taken for the computation of
.
Although reverse firewalls address one problem, they may create another one. Namely, protocol transcripts for protocol participants become different, and it becomes impossible to detect a man-in-the-middle attack by sending a MAC code of the communication transcript via an independent channel. Moreover, if the adversary finds a way to manipulate parameters
and
from CPace, then context switching will be possible. Namely, suppose that two sessions are run concurrently between
P and
and between
P and
. In that case, the adversary can change the connections on the fly: party
P from session 1 will be connected with party
from session 2, and party
P from session 2 will be connected with party
from session 1. Probably, for this reason, the specification of CPace [
5] has included the communication transcript in the derivation of
. Similarly, the modified CPace protocol from [
24] includes identities of the communicating parties as the arguments in the computation of the element
G used as the base for the Diffie–Hellman protocol (as a consequence, the session key depends also on the identities of the protocol participants). Note that reverse firewalls cannot be applied to SPAKE2 [
25] and SPAKE2+ [
26], as these protocols use the protocol transcript as input to the key derivation function. This, at least, shows the tendency in the design of standardized PAKE schemes.
An additional issue is that the reverse firewall increases the complexity of the protocol, while one of the design goals was to keep it as simple as possible. Last but not least, the reverse firewall can be subverted or poorly implemented. Thus, resilience against kleptographic attacks by the reverse firewall must also be shown. For example, while protecting CPace, the reverse firewall can apply rejection sampling to leak other secrets from the system. For example, a reverse firewall may facilitate user tracing.
Apart from reverse firewalls that disrupt malicious communication channels, there are two defense methods. The first method is to split the computation into two or more components so that no component can determine the random elements sent to another protocol party. In our case, this would mean creating (or ) so that no single component can enforce a particular property of that enables information leakage. Thus, if at least one component is honest, it is impossible to create a hidden communication channel. Unfortunately, it might be quite complex to put together the components originating from different sources and definitely too complex in the case of simple devices.
Another strategy is to deploy a unit that monitors the component executing the protocol. Such a trusted entity is usually called a
watchdog. We can assume that it can see all CPace messages; thus, according to the classification given in [
27], it is an
online watchdog. However, in most cases, a watchdog
would be physically located as an interface to a component (device)
that executes CPace. It is reasonable to assume that the communication between a watchdog
and
is hidden from the adversary. In fact, if
and
do not communicate over a local bus, then they can encrypt messages in such a way that kleptographic leakage on the surface of the ciphertexts (see, e.g., Section 9 in [
28]) is prevented.
We assume that the watchdog
for
and the other party executing the CPace protocol, for example a reader
, are separate entities because
might be run by the adversary (compare the scenarios discussed in
Section 2.1). While discussing possible malicious implementations in the next session, we focus on feasibility of watchdogs that would effectively detect deviations from CPace.
1.5. Our Contribution
Due to the Spartan design of CPace, one may expect that CPace is relatively safe against implementation attacks. One may have an impression that there is no attack point for undetectable functionalities enabling covert information flow to an adversary. For more complicated PAKE protocols, one can expect that the situation could be different. In fact, broad kleptographic channels can be constructed, for example, for PACE (our work-in-progress).
The paper [
24] states that CPace can be corrupted by “biasing the randomness utilized by the subverted algorithms” (randomness subversion) or by replacing the input to the algorithms (input subversion). However, the paper [
24] gives no clue as to how these corruptions might be used to the advantage of the adversary. Finding an attack impact is a crucial issue, as immunizing a protocol against attacks that do not bring any advantage to the adversary is likely to be an unnecessary effort from the practical point of view.
Our goal is to verify the extent to which intuition regarding CPace’s resistance to malicious implementations is justified by reality. Our main findings are as follows:
- 1.
There are surprisingly many ways to corrupt an implementation of CPace and create undetectable information channels to the adversary.
- 2.
Fixing the problems may require substantial changes in the protocol, thereby eliminating its primary advantages: simplicity, elegance, and ease of implementation.
We maintain a certain level of generality in our considerations, avoiding focusing on specific use cases or implementations. As a result, we do not analyze how to hide or mask malicious functionality from side-channel analysis, as this is specific to the implementation. This is intentional: providing an example implementation of an attack that demonstrates even moderate resistance to side-channel analysis would not only violate our organization’s code of ethics but would also be a crime in the authors’ jurisdiction.
As it will become clear, countering malicious implementation at the protocol level may require changes in the CPace protocol (cf. e.g., Figure 3 in [
24]) and increase the complexity of the system by introducing an additional component (a firewall in [
24], or a watchdog). The latter brings additional dependencies related to trust management. Therefore, the adequacy of these changes depends on the use case and risk analysis—at the protocol level, we do not find a simple panacea. Consequently, we suggest that in practice, the right way to deal with the problem of subversion attacks could still be to rely on certified software and hardware. For this reason, we discuss the assets to be protected and potential threats against PAKE schemes, which are relevant for subversion attacks. This reshapes the security context of evaluation of a cryptographic product—currently, subversion attacks are not considered in such evaluations. Note that protection profiles and security targets, created according to the Common Criteria framework, contain the section “Security Objective Rationale”, which should include the risk analysis mentioned above, which in turn may indicate adequacy of introducing an additional and independent system component like a firewall or a watchdog.