I am surprised no one mentioned The Shockwave Rider by John Brunner, published in 1975. Excerpt:

Then the answer dawned on him, and he almost laughed. Fluckner had resorted to one of the oldest tricks in the store and turned loose in the continental net a selfperpetuating tapeworm, probably headed by a denunciation group "borrowed" from a major corporation, which would shunt itself from one nexus to another every time his credit-code was punched into a keyboard. It could take days to kill a worm like that, and sometimes weeks.

I read it in late 70s/early 80s and don't remember much of it but this bit had burrowed its way in my subconscious. I have been meaning to re-read it along with Stand on Zanzibar but they would be too depressing in the present era!

On Nov 4, 2019, at 10:10 AM, Paul McJones <paul@mcjones.org> wrote:

Another possible source of inspiration — including the name “worm” — were the publications by John Shoch and Jon Hupp on programs they wrote at Xerox PARC around 1979-1980 and published in 1980 and 1982:

John F. Shoch and Jon Hupp:
 The “Worm" Programs — Early Experience with a Distributed Computation.
Xerox SSL-80-3 and IEN 159. May 1980, revised September 1980

John F. Shoch and Jon Hupp:
 The “Worm" Programs — Early Experience with a Distributed Computation.
CACM V25 N3 (March 1982)

On Nov 3, 2019, Paul Winalski <paul.winalski@gmail.com> wrote:

On 11/2/19, Warner Losh <imp@bsdimp.com> wrote:

the notion of a self propagating thing
was quite novel (even if it had been theoretically discussed in many places
prior to the worm, and even though others had proven it via slower moving
vectors of BBS).

Novel to the Internet community, perhaps, but an idea that dates back
to the 1960s in IBM mainframe circles.  Self-submitting OS/360 JCL
jobs, which eventually caused a crash by filling the queue files with
jobs, were well-known in the raised-floor world.

In hindsight people like to point at it and what a terrible thing it was,
but Robert just got there first.

Again, first on the Internet.  Back in 1980 I accidentally took down
DEC's internal engineering network (about 100 nodes, mostly VAX/VMS,
at the time) with a worm.  ...

Robert Morris worked as an intern one summer in DEC's compiler group.
The Fortran project leader told Morris about my 1980 worm incident.
So he certainly had heard of the concept before he fashioned his
UNIX/Internet-based worm a few years later.

-Paul W.