Jo is right.
My son is a full-on extrovert. He loves to talk to just about anyone.
Here's my suggestion: if you think he's going to blindly walk off with someone, don't leave him unsupervised. (Kind of the cardinal rule of free-range parenting-- know where your child's abilities lie and give them freedom incremental to what they've demonstrated they can handle.)
My son will chat with everyone hither and yon, but we talk (low stress) about certain scenarios.
He knows what to do if he gets separated from me when we're out. (sit down right where he is and wait for me, or find a mommy or daddy-- someone with little kids-- to help him). We review this when we go to the zoo or out to another crowded place. We talk about boundaries and where he's supposed to be at the park ("We're going to be at the play structure. If you want to go somewhere else, come and ask me." This is great for playdates, by the way.)
He knows not to help any grown ups to find a puppy or kitten or lost animal. Good grown-ups know that kids shouldn't help them find their pets, kids should stay with their parents. Good grown-ups will ask the other grown-ups to help them.
Good grown ups will not offer him food or treats or a present without asking mama or daddy first. Good grown-ups know to ask the parent.
He knows not to open the door for anyone, even if they ask him to. He knows that 'good grown-ups know that kids shouldn't open the door for anyone, so they won't ask you to open it for them. Mom and Dad have keys, so we won't ask you to open the door for us either." (handy for when I'm in the shower or bathroom or basement)
There are some good personal safety/stranger danger programs your son can attend. By and large, however, it's usually someone we know and trust that causes problems with our children's safety or molests them; very unusually is it some random stranger.