I'm trying to run new electrical wire from the basement to my 3rd floor apartment. There’s a cast iron vertical sewage pipe that goes in the exact route I’d like the wire to go. But there would be overlap with the first-floor toilet output. Obviously, I’d have to use wire that is suitable for wet conditions like UF-B. But I can’t find anything on if it’s okay to put electrical wire inside sewage lines. And if it is okay, what are the rules around it.
The answer is NO:
electrical wire has to be used in an approved manner.
UF is approved for direct burial and use in an approved wireway or other listed methods.
a sewer pipe is not an approved method in any of the articles associated with NEC 340.10: used permitted for underground feeder type UF.
the answer is NO it is not permitted.
I wouldn't. I'll leave it to others with more knowledge to tell you why it can't be done.
In a similar situation I discovered that there was a slight gap at the side of the pipe. I was able to attach a weight to a string a drop it down 40' beside a pipe after I removed some fire blocking material. Once the string ran the full length I pulled an extra 40' through attached my wire to the string with electrical tape and I was able to pull 8 Cat5e network cables up through the gap. I left the string there so if I ever need to add additional wires I can do so easily.
Express line to a red tag
Not only is this a bad idea practically speaking due to the high potential of leaking sewer gases into the house at the points the cable enters and exits the pipe, your proposal blatantly violates IRC P3101.3 (or IPC 901.4, which says the same thing):
P3101.3 Use limitations.
The plumbing vent system shall not be used for purposes other than the venting of the plumbing system.
So, I'd find a different route for the cable, even if you have to do a bit of probing around with a rented borescope or such and/or use a long, flexible installer bit to drill holes in members for the cable to route through.
I had a situation similar to this a year or two ago. My options became run a wire outside on the brick through conduit to get to 3rd floor apartment or find a way down. Luckily, I found the house was old enough I was able to find a path from 3rd floor to basement with no blockers and ran it that way. Unfortunately, unless the house is old enough that it didn't have a top and bottom plate on the walls, your going to have to either run outside and up the wall to get to the 3rd floor or get a hole or two in drywall to fish it up through to meet code.
By code you cant run wire through active plumbing pipes or even active HVAC supplies and returns.