I need help on this structure. I understand about reentrancy attack but I still figuring out read-only reentrancy why it needs extra 'A' contract.
In this scenario, contract A is not something that the attacker deploys, but some existing contract that the Target contract normally needs to read. Target reads some values from a view function in A, and trusts that they will be correct, since it assumes that at the time of reading it will be the only one interacting with A. The view function is not protected from reentrancy because it is not a security risk to A.
But A has some function that when called (1), allows the attacker to modify the values in A and call back Hack (2), which allows the attacker to continue the transaction to Target (3), which will call the view function from A (4), without knowing that it will have been manipulated just before.
Contract A could protect the Target from this attack by implementing an anti reentrancy mechanism in the view function, so that the 4th call could not be performed and the whole transaction would revert.