Honestly I couldn’t tell you whether copying code out of Stack Overflow or out of ChatGPT is more legally suspect. For SO, you don’t know where the user got the code from either (wrote it themselves? Copied it out of their work repo? Copied from some random GPL source?)