全てのリンク先で肝が冷えます。 PHPerの早朝のネタトークが思いの外インパクトがあったのでまとめただけです。 PHPや利用者がどうこうという文脈ではありません。 ※タイトル変更しました。
(Last Updated On: 2018年10月7日)Railsで多用されているActiveRecordのインジェクションパターンを簡単に紹介します。出典はrails-sqli.orgなのでより詳しい解説はこちらで確認してください。特に気をつける必要があると思われる物のみをピックアップしました。 Exists?メソッド User.exists? params[:user] params[:user]などの使い方は危険です。RailsはPHPなどと同様にuser[]というパラメーターで配列化します。 ?user[]=1 が入力の場合、 SELECT 1 AS one FROM "users" WHERE (1) LIMIT 1 となり不正なクエリが実行されます。 Calculateメソッド CalculateメソッドはSQLの集約関数を実行するメソッドです。average、calcula
IPA(独立行政法人情報処理推進機構)は、IPAが脆弱性の届出を受けたWebサイトで使用されているWebサーバ関連ソフトウェアのバージョン確認を実施し、その結果を踏まえ、サイト運営組織および管理者向けに「サーバソフトウェアが最新版に更新されにくい現状および対策」を4月25日からIPAのWebサイトで公開した。 IPAが、2013年4月15日から2014年1月16日にかけてJPCERTコーディネーションセンターが発表した四半期別のインシデント報告対応レポート4通をもとに算出したところ、Webサイトの改竄が7,409件発生したことがわかった。 それらの中には閲覧者のウイルス感染やWebサイトからの情報漏洩が発生しているが、原因の1つにWebサーバ構築に用いられているソフトが古いバージョンのままで、脆弱性が未修正であったことが挙げられる。 これを受け、IPAは「PHP」「Apache」「IIS」
IE のままじゃダメなの? ~ Microsoft Edge のメリットとこれからを見据えた Web システム運用のテクニック ~TAKUYA OHTA
JPEG画像のEXIFヘッダに隠された仕掛けられたマルウェアを、Sucuri Research Labの調査チームが発見しました。このマルウェアはPHPの機能を用いてEXIFヘッダを読み込ませ、自らを実行させるようになっていました。 Malware Hidden Inside JPG EXIF Headers | Sucuri Blog http://blog.sucuri.net/2013/07/malware-hidden-inside-jpg-exif-headers.html Sucuri Research Labのチームは攻撃サイト認定されたサイトでこのマルウェアを発見しました。通常、バックドアはBASE64変換やgzip圧縮で身を隠しますが、このマルウェアはJPEG画像のEXIFヘッダに隠されていて、PHPの機能を用いて実行されるようになっています。 まず、サイト内で見つかった
Krebsが自分のサイト(KrebsOnSecurity)に対して41,000超のWebサイトからDoSを受けていると報告しています。 このDoSはWoredpressのpingbackを悪用したものらしく、先日、Sucuriもpingback機能を悪用したDoSについて報告していました。 More Than 162,000 WordPress Sites Used for Distributed Denial of Service Attack WordPressの16万サイトが大規模攻撃の踏み台に、「Pingback」機能悪用 - ITmedia エンタープライズ pingbackを悪用したDoS方法 pingbackはハイパーリンクを設置したことを通知する仕組みですが、リモート投稿(XMLRPC)の機能(WordPressのxmlrpc.php)に対して次のPOSTを送信するとそのW
たにぐちまことさんの よくわかるPHPの教科書がこのたび改版されて、よくわかるPHPの教科書 【PHP5.5対応版】として出版されました。旧版はmysql関数を使ってSQL呼び出ししていましたが、mysql関数がPHP5.5にて非推奨となったための緊急対処的な内容となっているようです。つまり、従来mysql関数を呼び出していた箇所をmysqliの呼び出しに変更したというのが、主な変更点のようで、これ以外はあまり変更点は見あたりません。 既に、Amazonでは、熱烈な読者の方からの詳細のレビューが届いています。 神本御降臨! 言わずと知れたPHPプログラミング書籍のロングセラー。 2010年9月に発売された前作の改訂版。 PHPのバージョンも最新の5.5に対応、内容は前作と殆ど同じ。 少し前に前作を購入した方も本書を購入した方がいいでしょう。 【中略】 それにしても、帯の「3万人に読まれた定
正規表現によるバリデーション等で、完全一致を示す目的で ^ と $ を用いる方法が一般的ですが、正しくは \A と \z を用いる必要があります。Rubyの場合 ^ と $ を使って完全一致のバリデーションを行うと脆弱性が入りやすいワナとなります。PerlやPHPの場合は、Ruby程ではありませんが不具合が生じるので \A と \z を使うようにしましょう。 はじめに 大垣さんのブログエントリ「PHPer向け、Ruby/Railsの落とし穴」には、Rubyの落とし穴として、完全一致検索の指定として、正規表現の ^ と $ を指定する例が、Ruby on Rails Security Guideからの引用として紹介されています。以下の正規表現は、XSS対策として、httpスキームあるいはhttpsスキームのURLのみを許可する正規表現のつもりです。 /^https?:\/\/[^\n]+$/
Composer の以下の問題が 2 月半ばあたりから話題になっていました。 Limit Replace / Provides to packages required by name in root package or any dep · Issue #2690 · composer/composer https://github.com/composer/composer/issues/2690 一言で言うと、 条件によってはユーザの意図しないパッケージがインストールされてしまう という問題です。悪意のあるパッケージをインストールしたことに気づかれなければ、攻撃者の思い通りのコードを実行させることができてしまいます。 ざっくり説明すると、 Composer には fork したパッケージや、リネームしたパッケージ から 、元のパッケージを置き換えることのできる機能が存在する (本エン
4. デモ1:半端な先行バイトによるXSS • 半端な先行バイトとは – Shift_JIS、EUC-JP、UTF-8などマルチバイト文字の1 バイト目だけが独立して存在する状態 – 次の文字が、マルチバイト文字の2バイト目以降の文 字として「食われる」状況になる – input要素などの引用符「”」を食わせて、イベントハ ンドラを注入する攻撃 Copyright © 2010-2014 HASH Consulting Corp. 4 5. デモ1:PHPソース <?php session_start(); header('Content-Type: text/html; charset=Shift_JIS'); $p1 = @$_GET['p1']; $p2 = @$_GET['p2']; ?> <body> <form> PHP Version:<?php echo htmlspeci
「JSON文字列へのインジェクション」と「パラメータの追加」:NoSQLを使うなら知っておきたいセキュリティの話(2)(1/2 ページ) MongoDBを用いたWebアプリケーションで生じる可能性がある4種類の脆弱性のうち、今回は「JSON文字列へのインジェクション」と「パラメータの追加」のメカニズムと対策について説明します。 前回の「『演算子のインジェクション』と『SSJI』」では、MongoDBを用いたWebアプリケーションで生じうる脆弱性のうち「演算子のインジェクション」と「SSJI」について、攻撃の実例と対策について解説しました。今回はさらに、「JSON文字列へのインジェクション」と「パラメータの追加」について説明します。 JSON文字列へのインジェクション これまで見てきたように、PHP言語においては連想配列を指定してデータの登録処理や検索処理を実行できます。しかし型の扱いが厳格
なんだかやけに長い説明ばかり検索に引っかかったので書きました。 Linuxのローカル環境でDockerコンテナ内のXアプリ(GUIアプリ)を利用するには $ xhost localhost + を実行した後に $ docker run --rm --net host -e "DISPLAY" container_image_name x_app_binary_path とすれば良いです。 もっと読む SSHなどよく知られたサービスポートで何も対策せずにいると数えきらないくらいの攻撃リクエストが来ます。不必要なログを増やしてリソースを無駄にし、もし不用意なユーザーやシステムがあると攻撃に成功する場合もあります。 SshguardはC作られており、flex/bisonのパーサールールを足せば拡張できますがカスタム版をメンテナンスするのも面倒です。必要なルールを足してプルリクエストを送ってもマー
(Last Updated On: 2018年10月12日)HTTPセッション管理はWebセキュリティの中核と言える機能です。Webセキュリティの中核であるHTTPセッション管理に設計上のバグがある事は少なくありません。今回のエントリはPHP Webアプリ開発者ではなく、主にWebフレームワーク側の開発者、つまりPHP本体の方に間違いがあるという話しです。Webアプリ開発者の回避策も紹介します。 まずセキュリティの基本として「入力のバリデーションを行い、正当な入力のみを受け入れる」があります。しかし、PHPに限らず多くのセッション管理機構は当たり前の「入力のバリデーションを行い、正当な入力のみを受け入れる」を行っていません。セッションIDの再生成(リセット)も不完全な物が多いと思います。 参考: 知らないと勘違いする「合成の誤謬」の罠 開発者は必修、SANS TOP 25の怪物的なセキュリ
JALの6桁数字パスワード問題から派生して、JALのサイトがパスワードリマインダとして「現在のパスワード」を教えてくれることから、JALサイトではパスワードを平文保存しているのではないかという疑惑が持ち上がっています。それに対して、「いやいや、従来の主流と思われるソルト付きMD5ハッシュでの保存しても、実用的な速度でハッシュ値から元パスワードを『解読』できるよ」と、JALを擁護(?)するエントリが現れました。 パスワード問合せシステムを作る (clojureのreducers) この記事では、最初Clojureによる単純な総当たりで36秒、Clojureのreducersによる並列化で11秒でハッシュ値から元パスワードが求められるよ、と説明されています。まことに痛快な記事ですので、未読の方には一読をお勧めします。 とはいうものの、100万件のMD5の総当たりが、逐次実行で36秒、並列化して
一昨日のエントリ『書籍「気づけばプロ並みPHP」にリモートスクリプト実行の脆弱性』にて、ファイル送信フォームに対するCSRF攻撃の文脈で、私は以下のように書きました。 通常のHTMLフォームを使ったCSRF攻撃では、Content-Typeをmultipart/form-dataにすることまでは可能ですが、ファイルの中身とファイル名を指定する方法がありません。従って、HTMLフォームによる攻撃経路はありません。 大半の方は、「ああ、そうだよね」という感じでお読みいただいたように思いますが、昨日サイバーディフェンス研究所の福森大喜さんから、「それIE8以前ならできるよ」と教えていただきました。福森さんの許可を得て、以下にPoCを公開します。 <form enctype="multipart/form-data" action="pro_add_check.php" method="POST"
下記の文章は、PHPのセッションIDに対する攻撃についてFull Disclosure MLに2010年に投稿された文章を和訳したものです。訳者の意見としては、攻撃の成立条件は極めて厳しく、そこまで深刻度は高くないと考えています。 とはいえ、疑似乱数列への攻撃がどのように行われるのか、その可能性を示す文章は比較的珍しいもののように思います。暗号論的に安全な疑似乱数とは何か、なぜ必要なのかといった内容を間接的に教えてくれる面白い文章だと感じましたので、今回翻訳してみました。 (以下、原文の和訳です) 原文:http://seclists.org/fulldisclosure/2010/Mar/519 Advisory (c) 2010 Andreas Bogk <andreas () andreas org> Product:PHP Version:5.3.2 以降 脆弱性の種類:暗号論的な
さくらのVPSにアタックしてくる人たちを、ハニーポットなど使いながらその行動を観察した記録です。観察日記。 今回のネタは以下2つです。 *SSH honeypot(Kippo)を使った悪い人の行動観察、アンケート */cgi-bin/php (Apache Magica攻撃)の観察 なおこのスライドは、2013年12月7日のSecurity Casual Talks(すみだセキュリティ勉強会)での発表資料です。 http://ozuma.sakura.ne.jp/sumida/ またスライド中、動画は以下のURLで閲覧できます http://youtu.be/gp3SBjZNWHURead less
この投稿はPHP Advent Calendar 2013の13日目の記事です。昨日は@tanakahisateruのPHPが糞言語なのはどう考えても参照をポインタだと思っているお前らが悪いでした。 現在twitterのタイムラインで、史上空前のSQLのエスケープブームが起こっています。 オレオレSQLセキュリティ教育は論理的に破綻している | yohgaki's blog 「プリペアードクエリが基本だけど、動的に SQL を組み立てる場合もあるから、そういう場合に備えてエスケープも知っておいたほうがいいかも」 - Togetterまとめ エスケープとプレースホルダをめぐる議論 - Togetterまとめ SQLインジェクション対策としてのプリペアドステートメントとエスケープについての議論 - Togetterまとめ IPAの「安全なSQLの呼び出し方」が安全になっていた | yohgak
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く