AS_PATH

Problem

Your network hears: "I can reach 203.0.113.0/24." But where did that route come from, and through which networks has it travelled? Without history, routing loops are also difficult to detect.

Solution — AS_PATH

BGP advertisements carry the sequence of autonomous systems the route has passed through. 203.0.113.0/24 AS_PATH: 64510 64520 64530 Read left to right: AS64510 is the first external network on the advertised route, followed by AS64520, with AS64530 originating the destination prefix. If your own AS already appears in the path, you know accepting it would create a loop.
Core idea: AS_PATH records the inter-network path of a BGP route.