I doubt it's harmful. It MIGHT be a peanut worm---you never see those except as a proboscis protruding from the rock (they get into a hole a never leave it) I'd put it back in and see what it does. THere are many, many types of worms, mostly beneficixal to the tank.The ones that aren't tend to have distinct mouth parts (the Eunicid) or stinging projections (fire worm, not to be confused with the common bristle worm, a good guy and much to be desired; If it's gorgeous, it's likely the fireworm; if common, baby poo or pinkish or reddisj brown it's the bristleworm There's also the spaghetti worm, which looks like nest of baby worms, but they're all one at the root......