There's always a risk in doing that. You don't know what is on that moss, like parasites, bugs, etc.
Having that said, I plan on doing this myself with some moss that my cousin had recently found, but before adding in my moss I'm going to freeze it then run warm water through it in hopes of cleaning out anything that could be dangerous to my snake.
If I were you, I would research all I could about treating moss before putting it in, and that's only if you really want to put that specific moss in. Otherwise, you're better off buying.