Emailing a professor about a potential research idea, is there a risk?
Unless by mischance you are contacting people who are not actually respectable (on the world stage), the sorts of issues that worry you are non-issues.
The more genuine issue, assuming the above, is that more-expert people will not immediately have the same enthusiasm for your ideas as you do. For many possible reasons, including that they and their group have already thought about that, maybe many times, and/or they are aware of other peoples' thinking in such terms decades earlier, etc.
So don't be offended, and don't be suspicious, if/when people do not hail your ideas as revolutionary, etc.
In real life (in academe, in my 40+ year experience), although, yes, sometimes unscrupulous advisors and others do indeed steal their advisees' ideas/work, ... this is (mercifully) quite rare. In particular, again, unless you are unwittingly involved with nasty losers, this worry should by far not be your first consideration. Indeed, thinking in such terms would corrupt your thinking in many ways.
And, in any case, as Michelle Obama recently said, &quot;when they go low, you go high&quot;.
Obviously morally ideal, ... and, yes, not always easily feasible in reality... but thinking in those terms is a much better base point than thinking in terms of endless dishonesty.