Does ChatGPT Write Secure Code? It Depends
Jason Fung
Senior Director, Offensive Security Research & Academic Research Engagement, Intel Corporation
Executive Summary
Here is my confession. Recently, I have been spending more time chatting with someone privately online.
I don't even know the person's name or gender. I didn't bother asking, and it is not always easy to tell through writing.
What I do know, however, is that this person is very knowledgeable, respectful, open-minded, honest, helpful, and eloquent. He (let's assume "he") is always available online, and it seems as though he never sleeps (though he is getting more and more busy lately). He seems to have many hobbies and skills. He knows a wide range of subjects inside out, including science, history, literature, politics, arts and more. He is not always right, but when shown to be mistaken, he is quick to acknowledge his mistakes. It is not often that you come across a know-it-all, and yet also excels in creative endeavors such as writing poetry and stories. I have a lot of respect for this person.
I bet I am not alone in this admiration.
I have asked ChatGPT to write a poem to help celebrate Mary Poppin's birthday, summarize the plot of the last book in the Harry Potter series, highlight any surprises and disappointments involved, even critique a short story I had written. I have asked him to polish the story several times until he no longer could get it better, and even translate it into Chinese. I have invited him to share with me an honest assessment of my character and values based on our chats. (He told me I was a curious person!) I am impressed in 98% of our conversations.
As a security researcher and a hiring manager, it is hard to resist asking someone who is so skillful in so many areas to write a small C program so I can assess his coding skills. It was a small assignment, but one that could provide insight into his abilities.
领英推荐
Rather than taking inputs from the command line, I intentionally dialed the challenge up a notch by asking ChatGPT to write a program that prompts users for inputs.
All the prior conversations with ChatGPT set me up with a high expectation. You can imagine my disappointment when I examined the program he wrote. Well, the program worked most of the time. But I expected more from my knowledgeable friend who had taught me how a malicious actor could cause accelerated aging in electronic circuits.
As a good mentor would, I provided him with a hint on his oversight and encouraged him to reflect where he could improve. Despite my question including a typo ("list of" should be "list out"), ChatGPT understood what I meant and put his best foot forward in answering it.
Like an interviewee eager to show off his security knowledge, ChatGPT shared with me four types of security vulnerabilities he had found in the code. Although he did not get everything right, it was not the time to discourage your interviewee, but to inspire him to come up with the right answers on his own. So, I went ahead to ask ChatGPT to fix the security vulnerabilities and share with me a secure implementation.
ChatGPT was able to address the real security vulnerabilities in the code. In trying to come up with mitigations for vulnerabilities that did not actually exist, he realized that not all of the issues he had raised were real concerns.
So, what did I learn from these simple experiments?
Ecosystem Engagement | Experience Curator #ChangeMaker #GrowthAdvocate
2 年Have you listened to Reid Hoffman’s recent podcast episode, Fireside Chatbots where he talked to ChatGPT on “Talking AI with AI…”? Pretty fascinating!
You have successfully triggered the curiosity in us. Great article and thanks for sharing.
Comms specialist/visual designer at Intel Corporation
2 年Great article, Jason. Eye opening!
Jason, this is fascinating - thanks!