You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "AdamKorcz (via GitHub)" <gi...@apache.org> on 2025/01/23 13:36:09 UTC
[PR] Add DOM Configurator fuzzer [logging-log4cxx]
AdamKorcz opened a new pull request, #460:
URL: https://github.com/apache/logging-log4cxx/pull/460
Adds a fuzzer that targets `DOMConfigurator::configure()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929428005
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
It's writing the file a few lines below, so I believe this is properly writing out the data to a file and then having the `DOMConfigurator` parse the file that was just written.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929466213
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
For OSS-fuzz to deeply investigate the DOMConfigurator code, it would need to generate mostly valid log4cxx configuration which would be extremely unlikely, as admitted by this concluding comment in [this blog post](https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html)
> In practical terms, this means that afl-fuzz won't have as much luck "inventing" PNG files or non-trivial HTML documents from scratch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "AdamKorcz (via GitHub)" <gi...@apache.org>.
AdamKorcz commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1930188937
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
> For OSS-fuzz to deeply investigate the DOMConfigurator code, it would need to generate mostly valid log4cxx configuration which would be extremely unlikely, as admitted by this concluding comment in [this blog post](https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html)
>
> > In practical terms, this means that afl-fuzz won't have as much luck "inventing" PNG files or non-trivial HTML documents from scratch
libFuzzer will be able to explore the code because of its coverage-guided features. We can help it too by adding a seed and a dictionary which will greatly improve the fuzzers reach from the get go. Once the fuzzer is merged, I can add that to the OSS-Fuzz build files.
> What do you expect this fuzz test to achieve?
The fuzzer tests [mostly XML parsing.](https://github.com/apache/logging-log4cxx/blob/master/src/main/cpp/domconfigurator.cpp). The DOM configurator has 1000+ LoC which would be great to have fuzz coverage of. I don't see a reason to not test it.
> Have you considered mimicing the fuzz test in [libexpat](https://github.com/libexpat/libexpat/tree/master/expat/fuzz)?
No. Could you elaborate on the advantages of that?
> Testing DOMConfigurator::configure() with an empty file should be just a unit test.
The file will not be empty. The fuzzer writes the test case to the file and then invokes the DOM Configurator so that it parses it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 merged PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929382595
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
Did you mean to provide/generate `conf.xml`? Otherwise this is always going to fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "AdamKorcz (via GitHub)" <gi...@apache.org>.
AdamKorcz commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1930188937
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
> For OSS-fuzz to deeply investigate the DOMConfigurator code, it would need to generate mostly valid log4cxx configuration which would be extremely unlikely, as admitted by this concluding comment in [this blog post](https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html)
>
> > In practical terms, this means that afl-fuzz won't have as much luck "inventing" PNG files or non-trivial HTML documents from scratch
libFuzzer will be able to explore the code because of its coverage-guided features. We can help it too by adding a seed and a dictionary which will greatly improve the fuzzers reach from the first iterations. Once the fuzzer is merged, I can add that to the OSS-Fuzz build files.
> What do you expect this fuzz test to achieve?
The fuzzer tests [mostly XML parsing.](https://github.com/apache/logging-log4cxx/blob/master/src/main/cpp/domconfigurator.cpp). The DOM configurator has 1000+ LoC which would be great to have fuzz coverage of. I don't see a reason to not test it.
> Have you considered mimicing the fuzz test in [libexpat](https://github.com/libexpat/libexpat/tree/master/expat/fuzz)?
No. Could you elaborate on the advantages of that?
> Testing DOMConfigurator::configure() with an empty file should be just a unit test.
The file will not be empty. The fuzzer writes the test case to the file and then invokes the DOM Configurator so that it parses it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929430574
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
What do you expect this fuzz test to achieve?
Have you considered mimicing the fuzz test in [libexpat](https://github.com/libexpat/libexpat/tree/master/expat/fuzz)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "AdamKorcz (via GitHub)" <gi...@apache.org>.
AdamKorcz commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1930188937
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
> For OSS-fuzz to deeply investigate the DOMConfigurator code, it would need to generate mostly valid log4cxx configuration which would be extremely unlikely, as admitted by this concluding comment in [this blog post](https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html)
>
> > In practical terms, this means that afl-fuzz won't have as much luck "inventing" PNG files or non-trivial HTML documents from scratch
libFuzzer will be able to explore the code because of its coverage-guided features. We can help it too by adding a seed and a dictionary which will greatly improve the fuzzers reach from the first iterations. Once the fuzzer is merged, I can add that to the OSS-Fuzz build files.
> What do you expect this fuzz test to achieve?
The fuzzer tests [the XML parsing of the DOM Configurator.](https://github.com/apache/logging-log4cxx/blob/da0313eb333e4f76ed7ade48075025f64f9c29e9/src/main/cpp/domconfigurator.cpp#L1056). The DOM configurator has 1000+ LoC which would be great to have fuzz coverage of. I don't see a reason to not test it.
> Have you considered mimicing the fuzz test in [libexpat](https://github.com/libexpat/libexpat/tree/master/expat/fuzz)?
No. Could you elaborate on the advantages of that?
> Testing DOMConfigurator::configure() with an empty file should be just a unit test.
The file will not be empty. The fuzzer writes the test case to the file and then invokes the DOM Configurator so that it parses it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929420033
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
Testing DOMConfigurator::configure() with an empty file should be just a unit test.
A fuzz test of xml content would be a better use of oss-fuzz resources.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add DOM Configurator fuzzer [logging-log4cxx]
Posted by "AdamKorcz (via GitHub)" <gi...@apache.org>.
AdamKorcz commented on code in PR #460:
URL: https://github.com/apache/logging-log4cxx/pull/460#discussion_r1929397074
##########
src/fuzzers/cpp/DOMConfiguratorFuzzer.cpp:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#include "stdint.h"
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/xml/domconfigurator.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::xml;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ char filename[9] = "conf.xml";
+
+ FILE *fp = fopen(filename, "wb");
+ if (!fp) {
Review Comment:
`fopen()` creates the file if it doesn't exist, if that is what you are concerned of?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org