So it's illegal (against the rules anyway) to sell something that it's legal to give away... Makes about as much sense as the prostitution laws.
If students carrying money create "security problems," then this place has far worse problems than junk food.
In my old junior-high school, two students got suspended for one giving the other a Tylenol tablet. They never thought it was contraband dope, but they suspendedthem anyway. A tad excessive.