In the OPs situation, as shown in the
linked photograph, the cable can be fished under the floor boards as an alternative to guard strips or rerouting through the overhead.
Under the US National Electric Code cables running across the face of rafters in an accessible attic have to be fastened to running boards made of nominal One inch lumber. Cables that run exposed across the top of the joists in that situation must be protected by guard strips. The running boards mitigate the tendency people have to hang things from the cable. Guard strips protect the cable from feet and storage. Cables run parallel to the rafters or joists must be fastened so that no portion of the cable is within 1&1/4 inches of the either face of the rafter or joist. The NEC does provide provision for running the cables through bored holes in structural lumber but the holes must be within the center third of the width of the rafter or joist and must not be any closer to another hole or knot than three times the diameter of the hole in order to avoid compromising the physical strength of the lumber. The holes, like the cable itself must not be any closer to the exposed or sheathed faces of the lumber than One and one quarter inches. As another respondent has already opined staying as far away from the roof sheathing as those rules permit is a very good idea. If multiple cables need to be run parallel to the same stud or other similar dimension lumber the use of patent cable standoffs fastened to the side of the lumber is a good idea. If you run more than three cables through the same hole more than twice in a row you will have to calculate whether the cables temperature rating is adequate for the load even after you DE-rate that rating to compensate for the cables being bundled together for more than twenty four inches. If any of the structural components are made of engineered lumber; such as joists made of plywood webbed, two by flanged wooden I beams; or engineered wood trusses then all cutting or boring must only be done as specified in the manufacturers directions and / or markings.
Since that space will almost inevitably be used for storage at some point, it would be better practice to install the junction boxes on the side of the studs rather than on the face of them. This would make it less likely that storage would strike the box during handling. The NEC does not require that however. If you use four square boxes then it will be easier to apply finish rings to extend the face of the box out to the finished surface if you ever line that space with any interior finish. The NEC requires that a box's open face come within One Eight of an inch of noncombustible finish, such as sheet rock, and it requires that the face of the box come flush or protrude from any combustible finish such as ceder closet lining.
--
Tom Horne