I assume they're based on the creatures that dwelt in Mirkwood after the Shadow fell on it. The same creatures, i.e. orcs and spiders that the Hobbit fled westward from, a collective folk memory in a song.
The utter depth of Tolkien
Btw, I love this creepy version of it put to music.
https://www.youtube.com/watch?v=YOQo57KBtSM