In OSPF the RID is sent with every LSA. This is enough for any router in the AS to know when it is seeing a route it origionally generated. If there is one point of redistrubtion there is still no risk of looping.
When there are 2 points of mutual redistribtuion, there can be an issue where the OSPF native rotues will be seen as preferred by the other IGP becuase during redistribution back into the OSPF, the cost is lower than native. This can cuase some flapping but still no loops. It can be corrected a few ways, one being adjusting cost when redistributing external routes back into OSPF. Another would be simply filtering the native OSPF routes during redistribution (or w/distribute list in under ospf process).
Now, when we have multiple IGP's with multiple routers performing redistribution, things can get more interesting. AD can case next hop preference to set up loops. This is very brief summary to what I consider a complex topic.
A quick query found this document by a 4x CCIE.
Perhaps this is what you are looking for....
Guys I have a question...how do routing protocols prevent loops when mutual redistribution is enabled with a single point of redistribution. Check out this example
In my topology I have R3 doing the mutual redistribution between both routing domains but why if I enabled redistribution from OSPF into EIGRP (which caused R4 to get the routes from OSPF and marked them as D EX, these are shown in the above screenshot) routes displayed as external EIGRP do not get send back to OSPF when I enable distribution the other way around (EIGRP into OSPF). I know it wont do it and I know that if you have two points of redistribution loops can indeed occur, but what mechanism stops D EX routes from being sent to OSPF when I redistribute EIGRP into OSPF. I started to give some serious thoughts because when I enable one and then the other
I would appreciate clarification.
Those routes have Originating router in the updates to identify the redistributing router,so even if they somehow leak back to R3,R3 will not accept these routes.
But in your case R3 will not receive these routing updates from R4,because split horizon feature forbids R4 to send the updates out of its receiving interface.