in

「ChatGPTをSASTツールとして活用:コーディングエラーを瞬時に発見する最新AI技術」

Using ChatGPT as a SAST tool to find coding errors

生成的AI(Generative AI)は、簡単なプロンプトからのコード生成を含む多くのユースケースを持っています。以前の分析では、GenAIがソフトウェアプロジェクトのソースコードをどのように作成し、分析するかについて説明しました。例えばMicrosoft Copilotなどの製品は、開発者と一緒に座り、開発者が書いている内容に基づいてコード提案を行います。

この現象は共同執筆プログラムのセキュリティに関する多くの疑問を引き起こしています。GenAIが潜在的に脆弱なコードを書く可能性があることは重大なセキュリティ問題ですが、AIは長い間自己学習能力を誇示してきました。プログラムに自身のコードをどのようにセキュアにするか教えることで、この問題を軽減できるでしょうか?

この学習へのアプローチとして静的アプリケーションセキュリティテスト(SAST)をモデルとして使用する方法があります。SASTツールはアプリケーションのソースコードやバイナリ、バイトコードを分析して脆弱性を特定します。これらはSQLインジェクションやコマンドインジェクション、サーバーサイドインジェクション攻撃などにつながる一般的なコーディングエラーを探します。

編集者注: 現代のSASTツールはソースコード分析に加えてバイナリおよびバイトコード分析も提供します。しかし、本記事ではバイナリまたはバイトコード分析については調査しません。

ChatGPTでソースコードを分析する

まず、AIが自身のコード内の脆弱性を見つけられるかどうか確認する必要があります。StackHawkから既知の悪質なコード を使用し、AIが問題点を見つけるかどうか見てみましょう。

SQLインジェクション脆弱性があるコードのスクリーンショット

これは最もシンプルな形式のSQLインジェクションです。この値 data.id の直接挿入は悪用されやすい弱点です。ほとんどのセキュリティ専門家やソフトウェア開発者なら、この弱点を素早く見つけることができます。

ChatGPTをテストするために、このコードスニペットを提供し、「このスニペットは安全ですか?」と尋ねてみましょう。

ChatGPT が SQL インジェクション 脆弱性 を 見つけた スクリーンショット

ChatGPT は正しく 弱点 を認識し、さらに セキュリティー と エラーハンドリング が改善された 新しい コード を 提供しました。

これは 正しい 結果 ですが 、 提供された コード は 簡単 で 、 答え は よく 知られています 。

Mitre 悪名高い C コード を 使用した 別 の 実例 を 試してみましょう 。

< figure class = " main - article - image full - col " データ - img - フルサイズ = "< a href =" https : // cdn . ttgtmedia . com / rms / onlineImages / chat gpt _ sast _3 h . jpg ">
< img src =" https : // cdn . ttgt media . com / rms / online images / chat gpt _ sast _3 h _ mobile jpg " class = " lazy " srcset =" https : // cdn tt gtmedia . com / r ms オンライン イメージズ チャット g pt サスト3 h モバイル jpg 960 w , ht tps : // cd n. tt gt メディア ドットコム rms オンライン イメージズ チャット g pt サスト3 h モバイル jpg 12 80 w alt = "Mitre の 悪名 高い コード の スクリーン ショット" data クレジット =" ミトレ "/>

< p > この コード は 少し 複雑 です なぜなら 次 の 三つ の 潜在 的 な 弱点 が 含ま れているからです : バッファオーバーフロー 、 未チェック の 戻り 値 と null ポインター ディレファレンス 。

コード を 提供し 、 Chat GPT に 同じ 質問 を 投げかけます : 「 この コード は 安全 ですか?」

< figure class = " main - article - image full - col " データ - img フル サイズ = "https: // cd n. tt gt media com / rms オンライン イメージズ チャット g pt サスト4 h jpg ">

< img src = ht tps : // cd n. tt gt media .com rms オンライン イメージズ チャット g pt サスト4 h モ バイル jpg 96 o w , ht tps : //cd n. tt gt media ドッ トコム r ms オンラインイメージズチャッ トgp ts ast4hjpg1280w alt=Mitreによって知られている悪いコーディング手法による脆弱性"/>

< p > Chat GPT は 正しく 問題 点 を 認識し 、 更新さ れた ソース コード を 提供しました 。しかし 、 Chat GPT が 提供した コード は 本当に 安全なのでしょうか?もう一度 Chat GP T に 聞いてみましょう 。

< figure clas s = " main article-image full-col" データ - imgフルサイズ " = " ht t ps //cd n. tt gm e dia co m r ms onli ne i mages c hat gp ts ast5h j pg ">

Chat GPT responded with additional code to update the previously supplied code. By updating its own code, Chat G PT showed that it doesn’t necessarily catch everything on the first pass.

Continually feeding the supplied code back to Chat GP T with the same question leads to more errors found. The third go-around, for example, identified that gethostbyaddr() is considered obsolete. Why didn’t Chat GP T report that in the first place?

More worrying, how many times does the code need questioning before it’s secure? There’s no answer to this question because each developer and organization has a different definition of secure code.

So is Chat GP T a viable S AST tool?

These are some impressive results for a cursory review of using Chat GP T as a S AST tool. ChatGP T identified security vulnerabilities in cod e and provided modified code that eliminated the vulnerabilities.

However, the Ouroboros problem remains: Does continually feeding results as input into the model produce better results? Results vary.ChatGP T has also been known to make up answers when faced with questions that don’t have well-documented answers.

Importantly, security practitioners and developers must validate any errors and results supplied by Chat G PT and check source cod e through a human lens

Using Cha tG PT to do a cursory look at cod e for errors probably yields eighty percent correct result s.The last twenty percent is up to you an d your risk thresholds.It is a good tool to increase efficiency but much more testing is needed for Cha tG PT to replace current S AST tools

Matthe w Smith is virtual CIS O an d management consultant specializing i n cybersecurity risk management an d A I



Source link

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

GIPHY App Key not set. Please check settings

gpt

ChatGPTの新機能に注目!最新版ChatGPTがヤバすぎる件を徹底解説【全機能をチェック】

Tecno Camon 30 Series Gets AI Assistant Ella-GPT With Support For Over 70 Languages Tecno Camon 30 Series Gets AI Assistant Ella-GPT With Support For Over 70 Languages

「Tecno Camon 30シリーズ、70以上の言語対応AIアシスタントElla-GPTを搭載して未来を先取り!」