We are probably not talking about the CIA or James Bond.
Both sides used civilians as volunteer guides and/or informers. A civilian could easily pass the lines on his way to conduct business or visit a sick relative. When he returned, a report of what he had seen and heard along the way might be useful. If caught and exposed by the enemy, he would be at risk of being hung. But there's no record of civilian informers being employed by the Confederate government.
A 'real' spy would be a Confederate soldier who went behind enemy lines to gather information and knew he would be hung if caught.
Bluford Cornelius once sold a cow to a Confederate QM in Murphree's Valley (Nov 9, 1863), but there's no other record of a connection to the Confederate military.