In The Lord of the Rings: The Return of the King, the giant spider that attacks Frodo in Cirith Ungol is Shelob.
Shelob lives in a tunnel near the pass of Cirith Ungol, a route leading toward Mordor. Gollum guides Frodo and Sam there because he hopes Shelob will kill them, allowing him to recover the Ring. The spider first paralyzes Frodo with her sting and then attempts to carry him away.
Sam attacks Shelob with Sting and the Phial of Galadriel. The light from the Phial frightens her, and Sam wounds her badly enough to drive her back into her lair. Shelob is not merely an ordinary giant spider: the story identifies her as an offspring of Ungoliant, an ancient monstrous being from Tolkien’s wider mythology. A frequent mix-up is calling Shelob a creature created by Sauron; she is instead an independent monster that dwells near his realm.