In Star Trek II: The Wrath of Khan, Khan and his crew have hijacked the Defiant and have raised their shields. Fortunately, Kirk and company on the Enterprise have a way to disable them.

Spock: Reliant's prefix number is one six three zero nine.

Saavik: I don't understand.

Kirk: You have to learn why things work on a starship.

Spock: Each ship has its combination code.

Kirk: To prevent an enemy do what we're attempting. Using our console to order Reliant to lower her shields.

Wouldn't this trick work both ways? What would prevent hijacked ships from disabling Starfleet ships in the same way?

If Khan knew about the prefix codes, and Kirk had raised his shields, couldn't Khan have used Reliant's computers to look up the Enterprise's prefix codes and disabled its shields?

  • 6
    The whole point of the movie was that Khan was not experienced at space combat. He probably didn't even know the prefix code existed.
    – RichS
    Commented Jan 22, 2018 at 4:52
  • 1
    @Thunderforge I have often wondered the same question about the prefix codes. Creating a code that allows other ships to control yours remotely is a huge security flaw!
    – RichS
    Commented Jan 22, 2018 at 5:58
  • 2
    @RichS but it's 5 numbers... The odds of guessing it by accident must be trillions and trillions to one :p Commented Jan 22, 2018 at 7:30
  • 2
    @JonClements Just 5 numbers. Just 1 more digit than a smartphone lockout code. Maybe the starship computers drop the internet connection after 3 failed attempts. :-b
    – RichS
    Commented Jan 22, 2018 at 7:34
  • 2
    @JonClements I rewatched it last night. The Cardassians were originally asking just for the transponder code in order to track the Phoenix. When it looked like Phoenix was going to attack the freighter, Picard ordered Worf to send the nearest Cardassian warship the prefix codes (which Worf objects to, stating that they would have the ability to lower the Phoenix's shields).
    – Jonathan
    Commented Jan 24, 2018 at 18:01

4 Answers 4


One thing you have to remember, Kirk is an Admiral at that point. That means that he has authority not just on his own ship, but also on any ship in the fleet.

The only other time we've seen prefix codes used was during the TNG episode "The Wounded". Picard was ordered by Admiral Haden to track down the Phoenix when its captain went rogue and began attacking Cardassian ships. To my knowledge, it isn't explicitly stated how Picard has the Phoenix's code to give to the Cardassian ship.

Considering both instances involved a member of the admiralty, it's conceivable that this information is only available to members of the admiralty, or accessed on their authority. In which case, the Reliant wouldn't have had Enterprise's code, as no one on that ship would have had the authorization of a member of the admiralty.

  • I'm afraid I disagree. If a ship is commandeered, you can't count on the next Starfleet ship it meets to have an admiral on board. More likely there's a standard procedure: 1) Look up the target's prefix codes. (List may be restricted to command staff). 2) Change your own codes. 3) Fight the commandeered ship. 4) Transmit your new codes Starfleet in a Top Secret encoded message. (Step 4 can wait until the successful completion of Step 3.) Commented Sep 20, 2018 at 6:43
  • This wouldn't explain why Admiral Layton didn't give the Lakota the Defiant's prefix code in paradise lost.
    – Servitor
    Commented Sep 20, 2018 at 14:11
  • If a ship is commandeered, any ship sent after it would most likely be given the command codes by whatever admiral gave the order, as Picard probably was by Admiral Haden. Otherwise, why didn't Maxwell use his command authority to take control of the Enterprise in The Wounded? The first rule of security is separation of control. If you have access to A, you aren't also given control over B. A captain wouldn't have their own codes, and an Admiral wouldn't be given their own ship (Kirk being an unusual situation).
    – Jonathan
    Commented Sep 20, 2018 at 23:06
  • 1
    @Servitor, as shown in TWOK, the trick would only work against a crew who wouldn't expect it to happen, otherwise they just flick a switch. Maxwell got blindsided by it because he didn't expect the Cardassians to know what code to transmit, but even then, as demonstrated a few seconds later, he was back in the battle and won easily. His Ops officer probably knew where the switch was. Commented May 7, 2020 at 3:56

From the scene in question:

JOACHIM: Sir! Our shields are dropping!

KHAN: Raise them.

JOACHIM: I can't!

KHAN: Where's the override? The override?

Khan, despite his inexperience, understood what was happening, and knew there was a countermeasure available under the circumstances: a manual override. He simply didn't know where the relevant controls were. Had he or his crew attempted this maneuver first instead of Kirk, it presumably would have failed, as the Enterprise crew would have been more thoroughly trained with the relevant controls.

Presumably, after this scene, Spock or Scott acted off-camera to prevent Khan from trying the same trick, likely by changing the prefix codes.

  • 5
    Additionally, Enterprise was effectively unshielded for the balance of the movie, so it wasn't an issue.
    – Politank-Z
    Commented Jan 22, 2018 at 6:34
  • There's also the possibility that while Khan and Co. had manual control of the ship that they didn't have necessary access to the ship's library computer to get the codes (there's no evidence of that of course but just maybe...) Commented Jan 22, 2018 at 8:34
  • 3
    (mind you - given Star Fleet's amazing advances in security - I wouldn't be surprised if there was a bright red folder in front of Khan with "Top Secret Access Codes for remote controlling Star Fleet vessels" written on it that now and then shouted "I'm top secret - pretend I'm not here!") Commented Jan 22, 2018 at 8:44
  • And therein lies the rest of the answer. If used against a federation-controlled ship it's an annoyance. If used against a commandeered one it's probably a loss.
    – Joshua
    Commented Jul 23, 2018 at 15:32

There is an entirely more plausible explanation that is nevertheless, as far as I know, non-canon:

The prefix code is not meant for doing this, and what Kirk briefly refers to is actually quite a complex hack that he has been sitting on for some time - Kirk has been knowledgeable in computer hacking ever since his academy days - and must also have previously discussed with Spock in order for Spock to instantly understand his shorthand. Had Kirk ever disclosed the possibility of using this hack to Starfleet, it would have patched the hole. It's likely he's not even certain it will work, which is belied by his dialog in the movie itself.

When he says to Saavik

You have to learn why things work on a starship

He's actually flexing his hacker smugness, and it is not a direct pearl of wisdom to educate the cadet - it is not that simple, and once what he has just done is learned of it will probably never be possible again.*

*except for the lazy callback in The Next Generation.


Khan demanded Kirk hand over all data related to the Genesis project. Receiving said data was what created a back door into the system, which is why Reliant's shields went down the moment they made the transfer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.