I believe it is held on by clips on the bed rails, look up from inside the bed or just feel with your fingers.
If you took them off, you would see a uneven surface, nothing like truck bed rails that were made of smooth sheet metal.
I have not found any bed rail attachment, like a camper or shell that would bolt into the uneven surface.
Someone that works well with sheet metal should make a rail cap that bolts down, using those holes where the clips are. That way we could have a better looking rail top & it could be painted or get over the rail Line-X spray done, maybe even get them powder coated.
The tail gate cap was double sided taped on, at least on my 2009