Abstract We introduce a set of identities in the cohomology ring of elliptic fibrations which are equivalent to the cancellation of gauge and mixed gauge-gravitational anomalies in F-theory compactifications to four and six dimensions. The identities consist in (co)homological relations between complex codimension-two cycles. The same set of relations, once evaluated on elliptic Calabi-Yau three-folds and four-folds, is shown to universally govern the structure of anomalies and their Green-Schwarz cancellation in six- and four-dimensional F-theory vacua, respectively. We furthermore conjecture that these relations hold not only within the cohomology ring, but even at the level of the Chow ring, i.e. as relations among codimension-two cycles...