Permalink
Show file tree
Hide file tree
33 changes: 33 additions & 0 deletions
33
test/com/facebook/buck/cli/ParserCacheCommandIntegrationTest.java
1 comment
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Prevent deserialization of random objects
Summary: Fixed security issue with buck parser-cache command. This diff prevent deserialization of random objects. Reviewed By: jtorkkola fbshipit-source-id: 24e8221
- Loading branch information
1 parent
8ce226c
commit 8c55009
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/com/facebook/buck/parser/ParserStateObjectInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright 2013-present Facebook, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. You may obtain | ||
| * a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package com.facebook.buck.parser; | ||
|
|
||
| import com.facebook.buck.parser.thrift.RemoteDaemonicParserState; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.InvalidClassException; | ||
| import java.io.ObjectInputStream; | ||
| import java.io.ObjectStreamClass; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| /** A ObjectInputStream that will deserialize only RemoteDaemonicParserState. */ | ||
| public class ParserStateObjectInputStream extends ObjectInputStream { | ||
|
|
||
| private Set<String> whitelist; | ||
|
|
||
| public ParserStateObjectInputStream(InputStream inputStream) throws IOException { | ||
| super(inputStream); | ||
|
|
||
| whitelist = new HashSet<>(); | ||
| whitelist.add(RemoteDaemonicParserState.class.getName()); | ||
| } | ||
|
|
||
| @Override | ||
| protected Class<?> resolveClass(ObjectStreamClass desc) | ||
| throws IOException, ClassNotFoundException { | ||
| if (!whitelist.contains(desc.getName())) { | ||
| throw new InvalidClassException(desc.getName(), "Can't deserialize this class"); | ||
| } | ||
| return super.resolveClass(desc); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8c55009There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was assigned CVE-2018-6331