To date, U.S. cross-border operations from Afghanistan into Pakistan have taken three forms: the use of Predator drones to target Al Qaeda fighters (although such drones may be launched solely from within Pakistan); the "hot pursuit" of militants who engaged in raids from Pakistan against U.S. and allied forces in Afghanistan, as well as the Afghan government; and the deployment of special operations forces into Pakistan as a means of striking at Al Qaeda. These types of cross-border operations clearly implicate the jus ad bellum, in that they entail one state projecting highly coercive military force into another state. Arguably Pakistan has consented to at least some of these types of cross-border operations, but that consent is poorly documented, suffers from the conflicting and diffuse sources of authority within the Pakistani government, and ultimately may not endure given the vicissitudes of Pakistani domestic politics. As such, though consent is a powerful and useful basis for supporting the legality of U.S. cross-border operations, other justifications should be considered as well.
Assuming Pakistani consent is lacking, other justifications for U.S. cross-border operations must be considered. The U.N. Security Council has on several occasions addressed the legality of foreign forces in Afghanistan. Yet the Security Council's Chapter VII resolutions are best seen as either authorizing the presence of a multinational force designed to stabilize Afghanistan (without having as its mission counter-terrorism operations, let alone operations outside Afghanistan), or simply recognizing the inherent right of self-defense of the United States and its allies. The inherent right of self-defense (individual and collective) does justify U.S. cross-border operations that respond to raids by militants from Pakistan into Afghanistan, so long as the U.S. operations remain necessary and proportionate to the threat of those raids, and so long as the Afghan government consents to the presence of U.S. forces. Such self-defense would also support unilateral uses of U.S. force against Al Qaeda in Pakistan, either in the form of covert operations by special forces units or the launching of Predators from Afghanistan to strike at targets in Pakistan, so long as it can be shown that those Al Qaeda targets are ones that are supporting the cross-border raids into Pakistan, and so long as Pakistan is unwilling or unable to prevent Al Qaeda's support for those raids. A broader right of self-defense against Al Qaeda targets in Pakistan based on the attacks of 9/11, however, is far more problematic, since the requirements of necessity and proportionality likely preclude unilateral uses of force against a third state that was not implicated in those attacks.
Sean D. Murphy, The International Legality of U.S. Military Cross-Border Operations from Afghanistan into Pakistan, 84 Int'l Legal Stud. (2008).