Without clearly defined attacker capabilities nor security guarantees of the different components (public-key encryption, hash function, etc). It is not easy to say whether or not this protocol is "attachable".
Given that we are given "carte blanche", I'll show two PITM attacks based on varying security and attacker models.
The general attacker model: I assume an attacker with full control of the network, they can inject, reorder, modify and otherwise delete messages. Furthermore, the attacker is allowed to "register" new users at anytime.
Attack 1: Identity misbinding and the need for more than CPA secure PKE
As written, it seems the protocol should be secure as long as a "secure" PKE scheme is used. However, the basic notion of security as in semantic security is not enough. At a high level, at end of the attack, $A$ thinks that they are talking to $B$, while $B$ thinks they are talking to the the attacker say $E$.
To do so, we will exhibit a CPA secure PKE for which the attack is possible. Let $\mathcal E$ be a "hybrid" PKE scheme (otherwise based) on a trapdoor function. Where encryption of the message $m$ under $pk$, roughly consists of generating a random value $s$ then generate a symmetric encryption key $k = H(s)$. $k$ is then used to encrypt the message with a stream cipher like algorithm, creating a ciphertext $c$. The final ciphertext from the PKE scheme is $$\{m\}_{pk} = (enc_{PKE}(pk, s), c)$$
The attack works as follows.
- $ A\rightarrow B: c_1 = \{N_A,A\}_{pk(B)} $
- The attacker intercepts this message, creates a new user $E$, modifies the ciphertext to a value $c_1'$ such that it decrypts to $N_A, E$. This is possible since we are using a stream cipher.(We also assume for instance, that the nonce and the identities are of fixed lengths, etc...)
- $B$ decrypts the message and seems $E's$ identity therefore the second message is sent to $E$
- $B \rightarrow E: c_2 = \{N_A. N_B\}_{pk_E}$.
- $E$ decrypts $c_2$, and gets the nonces.
- $E \rightarrow A: c_2' = \{N_A, N_B\}_{pk_A}$
- $A \rightarrow B: c_3 = H(N_B, A, B)$
- $E$ intercpets dropbs $c_3$ and send $c_3' = H(N_B, E, B)$
From the flow above, the view of $A$ is the same as if it interacted with $B$, while the view of $B$ is as if it interacted with $E$.
Attack 2: Long-Term secret exposure and Key-Compromise Integrity
Here the attacker's capabilities are strengthened and we allow compromise of long-term secret keys. Now obviously, if $sk_A$ is compromised (and $A$ is yet unaware) the attacker can impresonate $A$ at will; however it seems normal to expect that if $A$ runs a session with an honest $B$, $A$ should have assurance about who she talked to. However in this attack, compromise of $sk_A$ implies that the attacker can impresonate anyone towards $A$.
The basic idea as above is that, a PITM attacker will be able to decrypt the second message $\{N_A, N_B\}_{pk_A}$. The attacker can now conclude the interaction with $A$ and "cut the wire" towards B. As a consequence, $A$ thinks they are talking $B$ while in fact talking to B.