We carry out direct numerical simulation of compressible square duct flow in the range of bulk Mach numbers M b = 0.2 − 3, and up to friction Reynolds number Re τ = 500. The effects of flow compressibility on the secondary motions are found to be negligible, as the typical Mach number associated with the cross-stream flow is always less than 0.1. As in the incompressible case, we find that the wall law for the mean streamwise velocity applies with good approximation with respect to the nearest wall, upon suitable compressibility transformation. The same conclusion also applies to a passive scalar field, whereas the mean temperature does not exhibit inertial layers because of nonuniformity of the aerodynamic heating. We further find that the same temperature/velocity relation that holds for planar channels is applicable with good approximation for square ducts, and develop a similar relation between temperature and passive scalars.