When the cue ball is in hand behind the head string, and the first ball the cue ball contacts is also behind the head string, the shot is a foul unless the cue ball crosses the head string before that contact. If such a shot is intentional, it is unsportsmanlike conduct.
The cue ball must either cross the head string or contact a ball in front of or on the head string or the shot is a foul, and the cue ball is in hand for the following player according to the rules of the specific game.