  Collisionless shocks are commonly argued to be the sites of cosmic ray (CR)
acceleration. We study the influence of CRs on weakly magnetized relativistic
collisionless shocks and apply our results to external shocks in gamma-ray
burst (GRB) afterglows. The common view is that the transverse Weibel
instability (TWI) generates a small-scale magnetic field that facilitates
collisional coupling and thermalization in the shock transition. The TWI field
is expected to decay rapidly, over a finite number of proton plasma skin depths
from the transition. However, the synchrotron emission in GRB afterglows
suggests that a strong and persistent magnetic field is present in the plasma
that crosses the shock; the origin of this field is a key open question. Here
we suggest that the common picture involving TWI demands revision. Namely, the
CRs drive turbulence in the shock upstream on scales much larger than the skin
depth. This turbulence generates a large-scale magnetic field that quenches TWI
and produces a magnetized shock. The new field efficiently confines CRs and
enhances the acceleration efficiency. The CRs modify the shocks in GRB
afterglows at least while they remain relativistic. The origin of the magnetic
field that gives rise to the synchrotron emission is plausibly in the CR-driven
turbulence. We do not expect ultrahigh energy cosmic ray production in external
GRB shocks.
